The idea behind the cursor pagination is to work as a pointer.
In the ElasticSearch, you have the _search method where you can use the scroll propriety. This method will group the documents based on the size.
GET /<index>/_search?scroll=<ttl, example: 1m>
{
"query": {
<parameters>
},
"size": <integer, example: 1000>,
}
For the next slices of documents, you will use _search method but only with the scroll and scroll_id propriety. Internally, ES will return only the next slice of documents without recalculate again the documents.
GET /_search/scroll
{
"scroll": <ttl, example: 1m>,
"scroll_id": <scroll_id hash>
}
You should avoid to use size and from proprieties due to performance constraints.
Have a look on: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-scroll