phpsearchsphinxmanticore-searchmanticore

How to use Manticore Regex using sphinxapi


I am using sphinxapi adding queries using addQuery() but It does add everything inside MATCH("...") and in Manticore there is Regex functionality apart from Sphinx. Do you know how to use this regex on php and runQueries() get results.


Solution

  • Well you cant write it exactly like that in SQL, would be something like

    SELECT id,name,REGEX(name, '^GALL\\w{0,3}$') AS filter FROM story WHERE filter=1; 
    

    So to translate that into the API

    $cl->setSelect("name,REGEX(name, '^GALL\\w{0,3}$') AS filter");
    $cl->setFilter('filter', array(1));
    $r = $cl->Query('', 'myindex');
    

    Basically have to create a virtual attribute as result of expression. Then filter by that. Not something can do in most actaul RDMS, but its how it done in sphinx/manticoew. filter is just an arbitary name I chose.