【发布时间】:2012-12-11 23:48:25
【问题描述】:
Sphinx 0.9.9 已配置为与 MySql 一起使用。
我最近注意到 Sphinx 不适用于包含多次出现 或 > 字符的搜索词。
工作 PHP 代码:
// Initialize SphinxClient class object
$cl = new SphinxClient ();
// Set the server and port
$cl->SetServer ( "127.0.0.1", 9313 );
// Initialize prefixed query
$query_prefix = '';
// Set the limit
$cl->SetLimits((int)$offset, (int)$count);
// Set the match mode
$cl->setMatchMode(SPH_MATCH_EXTENDED);
// Set the ranking mode
$cl->setRankingMode(SPH_RANK_WORDCOUNT);
// Set sorting
$cl->SetSortMode(SPH_SORT_EXTENDED,'@relevance DESC, updated_date DESC' );
$query_main = '@(name,description)';
// Initialize the search index
$search_index = 'index_common';
$search_text = $cl->EscapeString($search_text);
// Run the search query
$resp = $cl->Query($query_prefix . '('. $query_main . '"^' . $search_text . '$" | "' .
$search_text . '" | (' . $search_text . ') | "'
. $search_text . '"/1 | (' . $search_text_wild . ')) ' ,$search_index);
如果我输入“>>”之类的搜索词而不带引号,它会生成以下查询:
(@(name,description)"^>>$" | ">>" | (>>) | ">>"/1 | (*>>*))
并且不会给出任何响应,例如在系统中找不到搜索词时。这发生在多次出现的 和 > 上,而不是一次。
这是 Sphinx 中的一个已知问题还是有办法克服(让 Sphinx 在这些特殊情况下正常工作)?
【问题讨论】:
标签: php mysql search-engine sphinx