我是 Sphinx 的新手,并尝试在 sphinx.conf 中设置“索引”。
当我运行命令“indexer.exe --all --rotate --config C:\sphinx\etc\sphinx.conf”时,我发现了这样的错误:
using config file 'c:\sphinx\etc\sphinx.conf'...
indexing index 'warehouse1'...
ERROR: index 'warehouse1': first column in SQL query result must be document ID; found 'code_attr' attribute instead.
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
这是我的 sphinx.conf
source warehouse
{
type = mysql
sql_host = localhost
sql_user = sphinx
sql_pass = sphinx_password
sql_db = test
sql_port = 3306
sql_query_pre = SELECT @id := 0
sql_query = \
SELECT @id := @id + 1 AS code_attr, whse_id, whse_desc \
FROM warehouse
sql_attr_uint = code_attr
sql_field_string = whse_id
sql_field_string = whse_desc
}
index warehouse1
{
source = warehouse
path = C:\sphinx\data\warehouse1
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = C:\sphinx\log\searchd.log
query_log = C:\sphinx\log\query.log
read_timeout = 5
max_children = 30
pid_file = C:\sphinx\logsearchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = C:\sphinx\data
}
在我的 MariaDB 中,我有一个表名“仓库”,其中包含如下字段:
whse_id varchar(8) --> Primary Key
whse_desc varchar(40)
我该如何解决这个错误?请推荐更多狮身人面像知识我应该阅读更多。非常感谢你的帮助