我正在使用 Sphinx Search .它对我来说工作正常,除了一个问题:我需要排除一些特定字段不包含单词的条目。
在 MySQL 中看起来像这样的东西:
SELECT * FROM table
WHERE yescolumn = 'query'
AND othercolumn not like '%keyword%'
最佳答案
您可以使用 Sphinx 的扩展查询语法来选择要搜索的字段。尝试像这样通过 Sphinx 运行查询:
@yescolumn query @othercolumn -keyword
因此在 PHP 页面中,您可能有一个指向名为 $sphinx
的 Sphinx 数据库的链接:
$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$results = $sphinx->Query('@yescolumn query @othercolumn -keyword');
更多信息在这里:http://www.sphinxsearch.com/docs/current.html#searching
关于php - 使用 Sphinx 进行复杂查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2526407/