選擇不同的我的文檔的集合屬於少數作者:從elasticsearch
[
{ 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
感謝,
平硐
什麼分數的結果嗎? – ramseykhalaf
術語方面做得很好。你應該試試。 – shyos
喜@shyos如果長期小面方面,他們告訴我,有一些獨特的文件,而不是1。他們怎麼得分和其他文件中 - 2.我不認爲它可以分頁(例如,顯示20個文件跳過第一個300。不同的結果) - 3.他們不允許突出顯示和所有其他好處 –