我一直在尝试实施也可以检测的搜索查询建议功能 拼写错误的单词(使用metaphone形态)。我已经能够做到这一点了 范围,问题是某些查询字符串返回空 结果他们不应该。例如,请参见此示例:
已编入索引的搜索列表:
[ "clone samsung galaxy s5",
"samsung galaxy ace 4gb",
"samsung galaxy core i8262 battery",
"samsung galaxy grand duos premium copy",
"samsung galaxy grand prime g530",
"samsung galaxy k3",
"samsung galaxy note 3 red",
"samsung galaxy note pro 12.2 lte black",
"samsung galaxy note pro 12.2 p905 lte white",
"samsung galaxy s duos 2 s7582",
"samsung galaxy s4 pink twilight",
"samsung galaxy s5 2g",
"samsung galaxy s5 32gb",
"samsung galaxy s5 air shuffle",
"samsung galaxy s5 clone",
"samsung galaxy s5 clone korea",
"samsung galaxy s5 clone korea specs",
"samsung galaxy s5 dual core",
"samsung galaxy s5 dualcore",
"samsung galaxy s5 korean clone specs"]
query for "samsung ga": returns multiple results
query for "samsung gala": returns 0 results
query for "samsung galax" return multiple results
为什么"三星galax"和"三星ga"有结果,但"三星晚会"才不是。我没有实现任何类型的停用词控制,所以不是问题。我确定某些东西与我的索引有关。
以下是sphinx.conf文件中的相关索引:
index suggestions {
source = suggestions
path = /var/www/acme/maniac/sphinx/data/suggestions
morphology = metaphone
min_word_len = 3
min_infix_len = 2
}
我顺便通过php客户端这样做。这是执行的核心方法 狮身人面像搜索:
public function getKeywordSuggestions($queryString)
{
$this->sphinxClient->SetMatchMode('SPH_MATCH_ANY');
$this->sphinxClient->SetFieldWeights([
'keywords' => 50,
]);
$this->sphinxClient->SetSortMode(SPH_SORT_RELEVANCE);
$this->sphinxClient->AddQuery($queryString, 'suggestions');
$suggestionLimit = 10;
$this->sphinxClient->setLimits(0, $suggestionLimit, $suggestionLimit);
$sphinxResult = $this->sphinxClient->RunQueries();
/**
* do some of my other mojo
*/
return $result;
}
任何想法为什么会发生这种情况?
编辑:sphinx版本是2.2.1