【发布时间】:2010-03-26 20:10:39
【问题描述】:
我正在使用Sphinx Search。它对我来说很好,除了一个问题:我需要排除一些特定字段不包含单词的条目。
在 MySQL 中看起来像这样的东西:
SELECT * FROM table
WHERE yescolumn = 'query'
AND othercolumn not like '%keyword%'
【问题讨论】:
我正在使用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
【讨论】: