Sphinx ищет на латинице, а на кириллице – нет. Кодировка БД – UTF-8 Unicode (utf8), сравнение – utf8_unicode_ci.
Пример поиска на латинице:Запрос:
SELECT * FROM `category` WHERE MATCH('mol') LIMIT 10
В логе Sphinx:
[Mon Jun 24 18:37:43.275 2019] 0.000 sec 0.000 sec [ext2/0/ext 2 (0,10)] [category] mol
Результат:
{"categories":[{"id":9,"name":"Молочные изделия","keywords":"молоко"},{"id":30,"name":"Кофе молотый","keywords":""}]}
Пример поиска на кириллице:Запрос:
SELECT * FROM `category` WHERE MATCH('мол') LIMIT 10
В логе Sphinx:
[Mon Jun 24 18:42:03.530 2019] 0.000 sec 0.000 sec [ext2/0/ext 0 (0,10)] [category] мол
Результат:
{"categories":[]}
Конфиг Sphinx:source category_src
{
type = mysql
sql_host = 127.0.0.1
sql_user = root
sql_pass = root
sql_db = myproject
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT `category`.* \
FROM `category` \
WHERE `category`.`is_deleted` = 0
sql_attr_string = name
sql_attr_string = keywords
}
index category
{
source = category_src
path = /usr/local/var/data/category
docinfo = extern
dict = keywords
charset_type = utf-8
charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+401->U+451, U+451
blend_chars = &, ., +, U+23
morphology = stem_enru, soundex, metaphone
index_exact_words = 1
expand_keywords = 1
min_word_len = 1
min_prefix_len = 1
html_strip = 1
mlock = 0
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = /usr/local/var/log/searchd.log
query_log = /usr/local/var/log/query.log
read_timeout = 5
max_children = 30
pid_file = /usr/local/var/log/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = none
binlog_path = /usr/local/var/data
}