【问题标题】:Sphinx return empty result on cyrillic query狮身人面像在西里尔查询时返回空结果
【发布时间】:2012-11-01 12:56:00
【问题描述】:

使用拉丁语和俄语转译(!)仍然正常搜索

$ search sumka   
using config file '/etc/sphinx/sphinx.conf'...
index 'test1': query 'sumka ': returned 636 matches of 636 total in 0.000 sec

displaying matches:
1. document=154143, weight=1660, name=Сумка Sony LCS-MS10 Gray Alpha Текстильная сумка для фотокамеры Alpha Серый цвет, casual style (сумка почтальона) [LCSMS10H.AE], description_short=Сумка Sony LCS-MS10 Gray Alpha Текстильная сумка для фотокамеры Alpha Серый цвет, casual style (сумка почтальона) [LCSMS10H.AE]
                                     ...

$ search сумка

using config file '/etc/sphinx/sphinx.conf'...
index 'test1': query 'сумка ': returned 0 matches of 0 total in 0.000 sec

words:
1. 'сумка': 0 documents, 0 hits

这里听起来像字符集问题,但我在 mysql 中有 utf8 并查询

mysql> show variables like "character%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

mysql> show variables like "collation%";
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+ 

$ file words
words: UTF-8 Unicode text
$ cat words | search --stdin 

using config file '/etc/sphinx/sphinx.conf'...
index 'test1': query 'сумка
': returned 0 matches of 0 total in 0.000 sec

words:
1. 'сумка': 0 documents, 0 hits

php 客户端和 sphinx mysql 之类的客户端也是如此。

完整的狮身人面像配置是here,但重要部分的引用:

source src1
{
...
sql_query_pre       = SET NAMES utf8
sql_query_pre       = SET CHARACTER SET utf8
...
}
index test1
{
...
charset_type    = utf-8
...
}

我只发现了一个类似的问题,但是db中有latin1字符集。

程序版本是:

mysql  Ver 14.14 Distrib 5.5.20, for Linux (x86_64) using readline 5.1
Sphinx 2.0.6-id64-release (r3473)
centos 5.8

更新

添加 charset_table 以配置来自 http://sphinxsearch.com/wiki/doku.php?id=charset_tables#cyrillic 的表,但仍然不行。

我还在本地 gentoo 上安装了 Sphinx 2.0.5-release (r3308),它可以开箱即用地处理西里尔字母查询。

【问题讨论】:

    标签: mysql character-encoding sphinx


    【解决方案1】:

    你能用mysql接口试试吗? ( mysql -P 9306 -h 127.0.0.1 然后做一个 SELECT * FROM test1 WHERE MATCH('сумка'); )

    【讨论】:

    • 结果相同:0 个文档,0 个命中
    【解决方案2】:

    现在可以使用了。

    我不清楚它是什么,但它适用于默认配置和带有西里尔字母行的 example.sql,所以我转储了我的数据库并将其填满,它使它工作。 我认为它修复了一些编码问题,迁移后可能会抛出几个 mysql 实例。

    对不起我纯英语。:)

    【讨论】:

      【解决方案3】:

      问题可能是由于 mysql 编码。尝试取消注释此行:

      #sql_query_pre      = SET NAMES utf8
      

      mysql的默认编码可以不同于utf8;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多