【问题标题】:how to adjust sphinx to index phrases instead of words?如何调整 sphinx 以索引短语而不是单词?
【发布时间】:2014-10-13 11:03:31
【问题描述】:
我正在使用 sphinx 搜索引擎和 php。在我的 sql 表中,我有类似 this. mother keyboard, india pakistan, stakoverflow god 的内容。现在当我在它上面运行索引器时。它将“母亲和键盘”索引为不同的词。我希望它们作为一个短语进行搜索。我想要这个:如果只有mother 出现或只有father 出现,它不会搜索。我只会搜索mother keyboard 或keyboard mother 来。
提前致谢
【问题讨论】:
标签:
php
mysql
full-text-search
sphinx
【解决方案1】:
您可以尝试搜索确切的短语(这需要您启用index_exact_words)。
因此,使用 SphinxQL:
SELECT * FROM index WHERE MATCH('="mother keyboard" | ="keyboard mother"');
或者,NEAR 运算符可能会有所帮助:
SELECT * FROM index WHERE MATCH('mother NEAR/1 keyboard');
Sphinx 文档说 NEAR 将“当两个子表达式在彼此的 N 个单词中找到时匹配文档,无论以何种顺序。”
您可以阅读更多关于扩展查询语法here