How to show several docs with the same field?

I have documents that have a ”CompanyId” field that can be the same for multiple documents.

I want Elasticsearch to take up to 3 documents with the same “CompanyId” and the highest score, and then rank them in the overall output by comparing them with the score of other documents.

I use collapse, but all the collapsed documents remain in inner_hits and I can't get from there either: "collapse": { "field" : "CompanyId", "max_concurrent_group_searches": 3 "inner_hits": { "name" : "top_hits", "size":3, "sort": [{ "_score" : "desc" }]}}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.