【发布时间】:2017-03-03 03:15:47
【问题描述】:
我有 2 个狮身人面像索引:index1 和 index2。
当我在index1 中搜索时:我有两个匹配项:
{ error: '',
warning: '',
status: [ 0 ],
fields: [ 'name' ],
attrs: [],
matches:
[ { id: 5731, weight: 2, attrs: {} },
{ id: 17236, weight: 2, attrs: {} } ],
total: 2,
total_found: 2,
time: 0,
words: [ { word: '*foo*', docs: 2, hits: 4 } ] }
现在我可以从数据库中获取这两条记录并返回给客户端。
当我在index2 中搜索相同的词时:我得到了三个匹配项:
{ error: '',
warning: '',
status: [ 0 ],
fields: [ 'name' ],
attrs: [],
matches:
[ { id: 28, weight: 1, attrs: {} },
{ id: 41, weight: 1, attrs: {} },
{ id: 42, weight: 1, attrs: {} } ],
total: 3,
total_found: 3,
time: 0,
words: [ { word: '*foo*', docs: 3, hits: 3 } ] }
现在我可以从数据库中获取这 3 条记录并返回给客户端。
当我在所有索引中搜索时,我得到了 5 条记录:
{ error: '',
warning: '',
status: [ 0 ],
fields: [ 'name' ],
attrs: [],
matches:
[ { id: 5731, weight: 2, attrs: {} },
{ id: 17236, weight: 2, attrs: {} },
{ id: 28, weight: 1, attrs: {} },
{ id: 41, weight: 1, attrs: {} },
{ id: 42, weight: 1, attrs: {} } ],
total: 5,
total_found: 5,
time: 0,
words: [ { word: '*foo*', docs: 5, hits: 7 } ] }
问题是建立在不同数据库表上的索引。所以我实际上不知道如何处理匹配,因为 ids 引用了不同的表。
我怎样才能获得带有搜索结果或来源的索引名称,或者知道究竟找到了什么?
如果重要的话,我正在使用sphinxapi node.js 客户端。
【问题讨论】:
-
我是狮身人面像的新手。抱歉,我问了个假问题,我试着用谷歌搜索一下,真的
标签: node.js postgresql search full-text-search sphinx