# Getting all last documents with the same value?

**URL:** <https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668>\
**Category:** Elasticsearch\
**Created:** [October 4, 2017, 9:07am UTC](https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668 "2017-10-04T09:07:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [October 4, 2017, 9:07am UTC](https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668/1 "2017-10-04T09:07:10Z")

</div>

Hi friends,

Is it possible when sorting by a field, that we get all documents with the same value in the end (even if they are more than `size` value total docs returned ?

Meaning, if we have `size:2` and values that we sort are `[1,2,2,2,3,4,5]`, then we get back `[1,2,2,2]` since they have the same value (their ordering doesn't matter).

Thanks

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [October 10, 2017, 2:17pm UTC](https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668/2 "2017-10-10T14:17:26Z")

</div>

bump();

I know with the default min-heap it's not possible, but maybe using some kind of script ? Or it needs a custom plugin ?

Thanks

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [October 16, 2017, 10:25am UTC](https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668/3 "2017-10-16T10:25:07Z")

</div>

bump(2); Anybody any idea ?

---

<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:** [November 13, 2017, 10:25am UTC](https://discuss.elastic.co/t/getting-all-last-documents-with-the-same-value/102668/4 "2017-11-13T10:25:30Z")

</div>

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