【发布时间】:2013-07-30 14:10:21
【问题描述】:
我有一组属于少数作者的文档:
[
{ id: 1, author_id: 'mark', content: [...] },
{ id: 2, author_id: 'pierre', content: [...] },
{ id: 3, author_id: 'pierre', content: [...] },
{ id: 4, author_id: 'mark', content: [...] },
{ id: 5, author_id: 'william', content: [...] },
...
]
我想根据作者的 id 检索和分页选择的最佳匹配文档:
[
{ id: 1, author_id: 'mark', content: [...], _score: 100 },
{ id: 3, author_id: 'pierre', content: [...], _score: 90 },
{ id: 5, author_id: 'william', content: [...], _score: 80 },
...
]
这是我目前正在做的事情(伪代码):
unique_docs = res.results.to_a.uniq{ |doc| doc.author_id }
问题就在分页上:如何选择 20 个“不同”的文档?
有人指点term facets,其实我不是在做标签云:
- Distinct selection with CouchDB and elasticsearch
- http://elasticsearch-users.115913.n3.nabble.com/Getting-Distinct-Values-td3830953.html
谢谢,
修改
【问题讨论】:
-
结果中的分数是多少?
-
术语方面做得很好。你应该试试看。
-
嗨@shyos,如果术语方面是方面,他们告诉我有一些独特的文档,但不是 1. 他们如何在其他文档中得分 - 2. 我认为不可能分页(例如. 显示 20 个文档跳过前 300 个不同的结果)- 3. 它们不允许突出显示和所有其他好处
标签: elasticsearch grouping tire