Sphinx 思考斯芬克斯模糊搜索?

Sphinx 思考斯芬克斯模糊搜索?,sphinx,thinking-sphinx,Sphinx,Thinking Sphinx,我正在rails应用程序中实现sphinx搜索。 我想用模糊搜索。它应该搜索拼写错误,例如,如果输入搜索查询charact*a*ristics,它应该搜索charact*e*ristics 我应该如何实现这一点 默认情况下,Sphinx不注意使用星号字符的通配符搜索。不过,您可以打开它: development: enable_star: true # ... repeat for other environments 请参阅通配符/星型语法部分。斯芬克斯自然不允许拼写错误-它不关心单

我正在rails应用程序中实现sphinx搜索。
我想用模糊搜索。它应该搜索拼写错误,例如,如果输入搜索查询charact*a*ristics,它应该搜索charact*e*ristics

我应该如何实现这一点

默认情况下,Sphinx不注意使用星号字符的通配符搜索。不过,您可以打开它:

development:
  enable_star: true
  # ... repeat for other environments

请参阅通配符/星型语法部分。

斯芬克斯自然不允许拼写错误-它不关心单词拼写是否正确,它只是索引它们并匹配它们

围绕这一点,有两种选择:一种是在用户搜索时捕捉拼写错误,另一种是通过改进的查询为用户提供再次搜索的选择(就像谷歌那样);或者可以使用soundex或变音词的形态,以便对单词进行索引,以说明它们的发音方式。继续搜索词干,您将找到相关部分。也要对这件事有所了解


我不知道这两种选择有多可靠——就我个人而言,我会选择#1。

是的,斯芬克斯通常使用扩展匹配模式

有以下匹配模式可用:

SPH_MATCH_ALL, matches all query words (default mode);
SPH_MATCH_ANY, matches any of the query words;
SPH_MATCH_PHRASE, matches query as a phrase, requiring perfect match;
SPH_MATCH_BOOLEAN, matches query as a boolean expression (see Section 5.2, “Boolean query syntax”);
SPH_MATCH_EXTENDED, matches query as an expression in Sphinx internal query language (see Section 5.3, “Extended query syntax”);
SPH_MATCH_EXTENDED2, an alias for SPH_MATCH_EXTENDED;
SPH_MATCH_FULLSCAN, matches query, forcibly using the "full scan" mode as below. NB, any query terms will be ignored, such that filters, filter-ranges and grouping will still be applied, but no text-matching.
SPH_MATCH_EXTENDED2是在0.9.8和0.9.9开发周期中使用的,当时正在重写内部匹配引擎(为了增加功能和更好的性能)。到了0.9.9版本,旧版本被删除,SPH_MATCH_EXTENDED和SPH_MATCH_EXTENDED2现在只是别名

启用星号

在搜索前缀/中缀索引时启用星形语法(或通配符语法)。>可选,默认值为0(不使用通配符语法),以与0.9.7兼容。>已知值为0和1

例如,假设索引是用中缀构建的,并且enable_star为1。搜索应按以下方式进行:

"abcdef" query will match only those documents that contain the exact "abcdef" word in them.
"abc*" query will match those documents that contain any words starting with "abc" (including the documents which contain the exact "abc" word only);
"*cde*" query will match those documents that contain any words which have "cde" characters in any part of the word (including the documents which contain the exact "cde" word only).
"*def" query will match those documents that contain any words ending with "def" (including the documents that contain the exact "def" word only).
例如:

启用_星=1


谢谢pat,我曾想过使用raspell,但它不符合我的要求。我正在阅读电子邮件内容并搜索通过电子邮件订购的可能的产品名称。我无法向用户建议正确的选项。而raspell恰好将一些缩写名称替换为不相关的替代名称,如led(led)替换为lid。用soundex和metaphone也试过了,这对我来说提高了效果,但并不准确。