找到 Sphinx 重复文档 ID 对

Sphinx duplicate document id pairs found

我的重复索引问题不大。

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 return 问题实例。有什么想法吗?

你应该使用这个查询:

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。