# How to show several docs with the same field?

**URL:** <https://discuss.elastic.co/t/how-to-show-several-docs-with-the-same-field/334198>\
**Category:** Elasticsearch\
**Created:** [May 24, 2023, 9:20am UTC](https://discuss.elastic.co/t/how-to-show-several-docs-with-the-same-field/334198 "2023-05-24T09:20:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asebalo98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asebalo98/32/121376_2.png) [@asebalo98](https://discuss.elastic.co/u/asebalo98)\
**Post date:** [May 24, 2023, 9:20am UTC](https://discuss.elastic.co/t/how-to-show-several-docs-with-the-same-field/334198/1 "2023-05-24T09:20:52Z")

</div>

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" }]}}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 21, 2023, 9:21am UTC](https://discuss.elastic.co/t/how-to-show-several-docs-with-the-same-field/334198/2 "2023-06-21T09:21:05Z")

</div>

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