Pagination internal working using from/size

Hi,
I was looking at the documentation for pagination here: Pagination | Elasticsearch: The Definitive Guide [2.x] | Elastic
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

  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

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