Book Image

ElasticSearch Blueprints

Book Image

ElasticSearch Blueprints

Overview of this book

Table of Contents (15 chapters)
Elasticsearch Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Using the scroll API for consistent pagination


Let's imagine this situation; first, the user queries for all laptops. The user receives 1,000 results and goes through the first page of 10 results. Now, some additional documents get added and in the background, instead of 1,000 matched results, we get 1,200 matched results. Hence, when the user opens the next page, they see some overlaps from the first page or mostly see some inconsistent results based on the score or aggregation. The number of Lenovo laptops that were shown on the first page were 20, but on the second page, this increased to 50.

This was because there were additional documents added between the time the first and second pages were served.

Note

The scroll API gives provision for a point-in-time search. New document addition/deletion won't be taken into account while using the Scroll API.

If you want to use the scroll API, you would need to specify the scroll parameter in the query string. This scroll parameter indicates Elasticsearch...