2014-05-19 73 views
0

这里是我的查询Sphinxql查询如何Sphinxql查询构建器添加匹配模式

$query =SphinxQL::query()->select('*') 
    ->from('table1')->match('title','hel',)->execute(); 

    //title is column name 

我需要具有文本hel任何地方for eg mysql Like %string%

在高于其检索其匹配hel记录的记录也就是说

我需要添加setmatchmode(SPH_MATCH_ANY),我需要补充,这是Sphinxql查询

回答

3

坦率地说,你最好不要使用匹配模式,即使你在技术上可以通过SphinxQL。

代替仅仅使用仲裁语法重写查询....

->match('title',expr('"hel two there"/1')) 

编辑,以澄清可能需要使用表达式来避免自动转义由框架提供。 (感谢评论!)

+0

我会检查并感谢你。 –

+0

您可能需要将匹配包装在表达式中,否则控制字符将被转义。 Laravel图书馆使用Foolz \ SphinxQL(免责声明:我是创作者)。 ' - > match('title',\ Foolz \ SphinxQL \ SphinxQL :: expr(''hel two there'/ 1'))'。在match()上进一步阅读:https://github.com/FoolCode/SphinxQL-Query-Builder#match – Woxxy