# Getting Nth max/min record from a index

**URL:** <https://discuss.elastic.co/t/getting-nth-max-min-record-from-a-index/121444>\
**Category:** Elasticsearch\
**Created:** [February 26, 2018, 7:36am UTC](https://discuss.elastic.co/t/getting-nth-max-min-record-from-a-index/121444 "2018-02-26T07:36:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cj\_elastic](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@cj\_elastic](https://discuss.elastic.co/u/cj_elastic)\
**Post date:** [February 26, 2018, 7:36am UTC](https://discuss.elastic.co/t/getting-nth-max-min-record-from-a-index/121444/1 "2018-02-26T07:36:38Z")

</div>

I need to get nth max record. eg. get 100,000 th record which was created latest based on a field created\_time. I also have a custom doc\_id which is random. Or is there any other default field created by elasticsearch that could be used for this.

What would be the best approach for this requirement using java API 5.4 client

I could come up with scroll API mentioned here. Is there any better solution  
[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-scrolling.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-scrolling.html)

Thanks for reply,  
Jacob

---

<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:** [March 26, 2018, 7:36am UTC](https://discuss.elastic.co/t/getting-nth-max-min-record-from-a-index/121444/2 "2018-03-26T07:36:48Z")

</div>

Closed on March 26, 2018, 7:36am UTC

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