0

来自 sphinx.conf:

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 dict 是空的?这是获取表名的正确方法吗?如果不是,那是什么?

4

1 回答 1

1

确保在更改配置文件后重建索引

最好在更改配置后重新启动 sphinx

在查询中指定实际的索引名称,而不是仅使用 '*' - 所有索引都应具有必需的属性

于 2012-09-21T12:02:20.577 回答