The scroll parameter
In addition to paging using the parameters, from and size, Elasticsearch also supports the scroll parameter, and works like a forward-only cursor. It keeps the search context active, just like a snapshot corresponding to a given timestamp.
Basically, if you need to process the returned results further and continue after the process, you need to keep such a snapshot. An identifier, _scroll_id, is provided in the result of the initial request so that you can use the identifier to get the next batch of results. If there are no more results, an empty array is returned in hits. You can use the size parameter to control the number of hits returned in the batch.
Let's look at an example where scrolling is executed three times ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access