今天在配置完sphinx新索引后,生成索引时报错
indexing index 'eaxing'...
WARNING: attribute 'id' not found - IGNORING
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.011 sec, 2414112 bytes/sec, 1921.22 docs/sec
原因是sphinx不能使用主键来做属性字段,而我的源配置里是这么写的
sql_query = SELECT id, discussion_id,content FROM sq_posts
sql_attr_uint = id
sql_attr_uint = discussion_id
id是我posts表的主键,所以需要给个别名,like this
sql_query = SELECT id,id as aid, discussion_id,content FROM sq_posts
sql_attr_uint = aid
sql_attr_uint = discussion_id
然后再试试生成索引
./indexer -c /usr/local/coreseek/etc/csft.conf --all --rotate
indexing index 'eaxing'...
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.010 sec, 2573210 bytes/sec, 2047.84 docs/sec
ok了,这下就没错了。