Z
Z
zaartix2019-07-05 12:00:43
elasticsearch
zaartix, 2019-07-05 12:00:43

How to implement pagination on elasticsearch via scroll/slice?

Let's say you need to remake the classic pagination through size / from to scroll. At the output, have a page rewind with a list of the number of pages:
1, 2, 3 ... 100500
I.e. the user or the search engine can immediately go to page 100499 from the first page.
From the documentation, I understood that scroll creates, as it were, a snapshot of the issue, and through slice it is somehow possible to move along this snapshot. For slice, the id and max parameters are written in the documentation, I don’t really understand what it is, please explain.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kotofey, 2019-07-05
@kotofey

scroll serves other purposes
For pagination, just specify parameters such as from and size

GET /_search
{
    "from" : 0, "size" : 10,
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question