2012-09-20 69 views
0

從sphinx.conf中:如何知道在Sphinx中檢索到哪個表記錄?

source src0 { 
    type = pgsql 
    sql_host = localhost 
    sql_user = <db user> 
    sql_pass = <pwd> 
    sql_db = <db name> 
    sql_port = 5432 
    sql_query = \ 
     SELECT id, header, text, "app_main" as table_name \ 
     FROM app_main 
    sql_query_info = SELECT * FROM app_main WHERE id=$id 
    sql_attr_string = table_name 
} 

source src1 { 
    type = pgsql 
    sql_host = localhost 
    sql_user = <db user> 
    sql_pass = <pwd> 
    sql_db = <db name> 
    sql_port = 5432 
    sql_query = \ 
     SELECT id, header, text, "app_product" as table_name \ 
     FROM app_product 
    sql_query_info = SELECT * FROM app_product WHERE id=$id 
    sql_attr_string = table_name 
} 

index global_index { 
    source = src0 
    source = src1 
    path = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data/global_index 
    docinfo = extern 
    charset_type = utf-8 
} 

命令

client.Query(S, '*') 

回報

{'status': 0, 'matches': [{'id': 5, 'weight': 30, 'attrs': {}}], 'fields': ['header', 'text'], 'time': '0.000', 'total_found': 1, 'warning': '', 'attrs': [], 'words': [{'docs': 1, 'hits': 2, 'word': 'styless'}], 'error': '', 'total': 1}) 

爲什麼ATTRS字典是空的?這是獲取表名的正確方法,如果不是 - 是什麼?

回答

1

確保您在更改配置文件

最好在更改配置

在查詢中指定的實際指數姓名(或名稱),而不是僅僅使用後重新啓動獅身人面像後重建索引「*」 - 所有索引應具有必需的屬性

相關問題