# Pagination: Determine Page Number Of A Record

**URL:** https://discuss.elastic.co/t/pagination-determine-page-number-of-a-record/18342
**Category:** Elasticsearch
**Created:** [June 25, 2014, 7:10pm UTC](https://discuss.elastic.co/t/pagination-determine-page-number-of-a-record/18342 "2014-06-25T19:10:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bbehling](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@bbehling](https://discuss.elastic.co/u/bbehling)
#### Post date: [June 25, 2014, 7:10pm UTC](https://discuss.elastic.co/t/pagination-determine-page-number-of-a-record/18342/1 "2014-06-25T19:10:34Z")

</div>

I have a requirement where a document could be anywhere in a result set and  
I need to calculate a page number according where this document is in the  
results. I've been trying many different ideas such as using a script to  
calculate the page number based on the total count and a counter variable,  
but the counter keeps getting reset every time a shard is queried.

I also tried returning the entire result set and calculating this value in  
.net, but ES takes too long to complete a query request for sizes of 8000  
or more. I realize we shouldn't be returning these many features, but the  
scan and scroll is not an option because I will need to parse each response  
to see if the document I'm looking for is in it.

From and size also wont work because I have no idea what the 'from' value  
will be, and that is the value I'm trying to calculate.

I guess my question is, does any one have an idea of how to calculate a  
page number for a given document inside a query result?

Perhaps there is some functionality in ES that will tell you a document  
with a certain ID is the n'th document in the entire result set?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3c2458c1-629c-42d8-8a7e-551c6c093cda%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3c2458c1-629c-42d8-8a7e-551c6c093cda%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 1:19am UTC](https://discuss.elastic.co/t/pagination-determine-page-number-of-a-record/18342/2 "2017-07-06T01:19:43Z")

</div>


