【问题标题】:Wildcard search issue sphinx通配符搜索问题 sphinx
【发布时间】:2012-10-23 23:04:51
【问题描述】:

在 Sphinx 2.0.6 中尝试启用通配符 (*) 的搜索时出现以下错误

索引产品:语法错误,“*”附近出现意外的 $undefined

我的搜索词是iphone 4s*

它使用下面定义的产品索引。

index users
{
  enable_star = 1
  docinfo = extern
  morphology = stem_en
  charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
  ignore_chars = U+0021..U+002F,U+003A..U+003F,U+0060
  charset_type = utf-8
  html_strip = 0

  source = gdgt_user
  path = /var/lib/sphinxsearch/data/gdgt/users
  min_infix_len = 3
  min_word_len = 3
}

index products : users
{
  enable_star = 1
  min_infix_len = 1
  min_word_len = 1
  source = gdgt_products
  path = /var/lib/sphinxsearch/data/gdgt/products
}

我正在使用可以在源 tar 球中找到的 php api。 使用搜索 CLI 时,我可以看到错误。

search -c app/config/sphinx.compiled.conf -i products -e "ipho*"
Sphinx 2.0.6-id64-release (r3473)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file 'app/config/sphinx.compiled.conf'...
index 'products': search error: .

我的 php 代码看起来像

$client = new SphinxClient();
$client->SetServer($serverIp, $serverPort);
$client->SetMaxQueryTime(5000);
$client->SetSortMode(SPH_SORT_RELEVANCE);
$client->SetMatchMode(SPH_MATCH_EXTENDED);
$res = $client->query('ipho*', 'products');

var_dump($res, $client->getLastError(), $client->getLastWarning());

【问题讨论】:

    标签: sphinx thinking-sphinx django-sphinx


    【解决方案1】:

    问题是通配符的星号(*)也在你的 ignore_chars (U+002A) 中。

    更新为:

    ignore_chars = U+0021..U+0029,U+002B..U+002F,U+003A..U+003F,U+0060
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      相关资源
      最近更新 更多