Pagination with a standard query works very well if you are matching documents with documents that do not change too often; otherwise, performing pagination with live data returns unpredictable results. To bypass this problem, Elasticsearch provides an extra parameter in the query: scroll.
Executing a scroll search
Getting ready
You need an up-and-running Elasticsearch installation, which you can get as described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
A Maven tool, or an IDE that natively supports it for Java programming such as Eclipse or IntelliJ IDEA, installed.
The code for this recipe is in the ch13/high-level-client directory and the referred...