3

Sphinx 2.0.6でワイルドカード(*)を有効にした検索を試行しているときに、次のエラーが発生します

インデックス製品:構文エラー、予期しない$ undefined near'*'

私の検索用語は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ボールにあるphpapiを使用しています。検索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());
4

1 に答える 1

5

問題は、ワイルドカードのスター (*) が ignore_chars (U+002A) にも含まれていることです。

次のように更新します。

ignore_chars = U+0021..U+0029,U+002B..U+002F,U+003A..U+003F,U+0060
于 2012-10-26T00:12:19.633 に答える