經過大量的測試我已經完成了我一直在尋找通過修改的sphinx.conf文件中源{PREFIX} main_posts {}的SQL查詢,如下:
sql_query = select \
p.ID*2+1 as ID, \
0 as comment_ID,\
p.ID as post_ID,\
p.post_title as title, \
p.post_content as body, \
t.name as category, \
my_metakey_meta.meta_value as my_metakey, \
.
.
.
from \
{wp_posts} as p \
left join \
{wp_term_relationships} tr on (p.ID = tr.object_id) \
.
.
left join \
wp_postmeta my_metakey_meta on (p.ID = my_metakey_meta.post_id and my_metakey_meta.meta_key = 'my_metakey') \
.
.
.
where \
p.id>=$start AND p.id<=$end and \
p.post_status = 'publish' and \
my_metakey_meta.meta_value != '' \
group by p.ID
並修改了source {prefix} main_comments {}的SQL查詢如下:
sql_query = select \
.
.
'' as category, \
'' as my_metakey, \
.
.
.
更改sql_query後,需要重建索引。你使用索引器重建? – barryhunter 2014-12-15 10:43:18