重复索引的问题很少。
sql_query = SELECT id, title, file_id as table_id, "0" as description, "0" as content, "file" as type FROM language_files UNION ALL \
SELECT id, title, id as table_id, "0" as description, "0" as content, "list" as type FROM file_lists UNION ALL \
SELECT id, title, id as table_id, description, "0" as content, "tip" as type FROM tips UNION ALL \
SELECT id, title, id as table_id, "0" as description, content, "question" as type FROM questions
此代码与我的sphinx配置相同。如果匹配的questions.id和files.id相同,那么Sphnix返回问题实例。有什么想法吗?
答案 0 :(得分:2)
您应该使用此查询:
sql_query = SELECT ((id<<3)+1) as id, title, file_id as table_id, "0" as description, "0" as content, "file" as type FROM language_files UNION ALL \
SELECT ((id<<3)+2) as id, title, id as table_id, "0" as description, "0" as content, "list" as type FROM file_lists UNION ALL \
SELECT ((id<<3)+3) as id, title, id as table_id, description, "0" as content, "tip" as type FROM tips UNION ALL \
SELECT ((id<<3)+4) as id, title, id as table_id, "0" as description, content, "question" as type FROM questions
它将为不同的表生成不同的id。