4

私は少数の著者に属するドキュメントのコレクションを持っています:

[
  { 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個の「異なる」ドキュメントを選択するには?

一部の人々は用語 facetsを指摘していますが、私は実際にタグクラウドを行っていません:

ありがとう、
アディット

4

2 に答える 2