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 ...

Get Elasticsearch Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.