我在 MySQL 中有一张表
CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`article` varchar(50) NOT NULL,
`oem` varchar(50) NOT NULL,
`size` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1 ;
INSERT INTO `test` (`id`, `article`, `oem`, `size`) VALUES
(1, '92S400', '11223', '300x200x200'),
(2, '92S400', '11224', '300x150x200');
狮身人面像中的索引
source s_test
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass = 123
sql_db = auto
sql_port = 3306
sql_query_pre = SET NAMES cp1251
sql_query_pre = SET CHARACTER SET cp1251
sql_query = \
SELECT \
id `id`, \
'stub' as `stub`, \
article `article`, \
oem `oem`, \
size `size` \
FROM \
test
sql_attr_string = article
sql_attr_string = oem
sql_attr_string = size
sql_query_info = SELECT * FROM test WHERE id=$id
}
index i_test
{
source = s_test
path = /var/lib/sphinx/i_test
min_word_len = 1
enable_star = 0
min_prefix_len = 3
expand_keywords = 1
index_sp = 0
stopword_step = 1
dict=crc
}
index rt_test
{
type = rt
rt_mem_limit = 2047M
path = /var/lib/sphinx/test
enable_star = 1
min_prefix_len = 3
expand_keywords = 1
dict = keywords
morphology = stem_en
charset_table = 0..9, A..Z->a..z, _, a..z, U+A8->U+E5, U+B8->U+E5, U+C0..U+DF->U+E0..U+FF, U+E0..U+FF
rt_field = article
rt_field = oem
rt_attr_string = size
}
我在 shell 中运行命令:
searchd --stop
rm /var/lib/sphinx/*
indexer --all
searchd
例如,如果使用“INSERT”命令插入 rt_test 数据
INSERT INTO rt_test VALUES (1, '92S400', '11223', '300x200x200'),
(2, '92S400', '11224', '300x150x200');
'select .. MATCH' 没有问题:
SELECT * FROM rt_test WHERE MATCH('@oem 11223')\G;
*************************** 1. row ***************************
id: 1
weight: 1643
size: 300x200x200
但是如果我删除文件,重新运行索引器并运行附加命令
ATTACH INDEX i_test TO RTINDEX rt_test;
Sphinx 在之前的“SELECT .. MATCH”查询中显示错误:
ERROR 1064 (42000): index rt_test: query error: no field 'oem' found in schema
mysql 表中的数据存在于 rt_index 中。为什么会消失索引 rt_oem 和 rt_article?
PS Sphinx 2.0.8-release (r3831),Xubuntu x64