# Pagination internal working using from/size

**URL:** <https://discuss.elastic.co/t/pagination-internal-working-using-from-size/101919>\
**Category:** Elasticsearch\
**Created:** [September 27, 2017, 2:35am UTC](https://discuss.elastic.co/t/pagination-internal-working-using-from-size/101919 "2017-09-27T02:35:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addhawan](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@addhawan](https://discuss.elastic.co/u/addhawan)\
**Post date:** [September 27, 2017, 2:35am UTC](https://discuss.elastic.co/t/pagination-internal-working-using-from-size/101919/1 "2017-09-27T02:35:25Z")

</div>

Hi,  
I was looking at the documentation for pagination here: [Pagination | Elasticsearch: The Definitive Guide [2.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/pagination.html)  
which mentions :

> Results are sorted before being returned. But remember that a search request usually spans multiple shards. Each shard generates its own sorted results, which then need to be sorted centrally to ensure that the overall order is correct.

Question:

1. Assuming there is no ongoing indexing in the cluster, will ES always return the query results in the same order for each request?

2. If yes, then we can guarantee that if we paginate, we will not see any duplicate/missing records in the paginated results.

3. Also, for a search query, after collecting each shards own sorted results, does ES sort the results again before returning to the client?

4. What is the field used to sort by shards and ES?

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 27, 2017, 7:30am UTC](https://discuss.elastic.co/t/pagination-internal-working-using-from-size/101919/2 "2017-09-27T07:30:05Z")

</div>

1. Yes. Assuming the cluster is super stable and that replicas are exactly aligned to primary shards.

2. Yes.

3. Yes. The coordinating node (the node that gets the request) does that.

4. `_score` by default.

See also "scroll" API for consistent pagination. [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html)

---

<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:** [October 25, 2017, 7:30am UTC](https://discuss.elastic.co/t/pagination-internal-working-using-from-size/101919/3 "2017-10-25T07:30:25Z")

</div>

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