【问题标题】:Search failed for multiple < or > in Sphinx 0.9.9在 Sphinx 0.9.9 中搜索多个 < 或 > 失败
【发布时间】: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


    【解决方案1】:

    > 语法。

    所以这可能会导致问题。您可以尝试转义它们,我猜 EscapeString 不会这样做。

    但请记住,除非 在您的字符集表中,否则它们将永远无法匹配。

    (另外,当你说你没有得到回应时,一定要检查$cl-&gt;getLastError()!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多