Why is /_search with scroll different?

I have this api search (ES 7.10.2)

https://host:19102/myindex/cat/_search?filter_path=hits.total

that returns

{
    "hits": {
        "total": {
            "value": 10000,
            "relation": "gte"
        }
    }
}

Ok, I hit he 10.000 mark.

When using this call

https://host:19102/myindex/cat/_search?scroll=1m&filter_path=hits.total

I get

{
    "hits": {
        "total": {
            "value": 23012,
            "relation": "eq"
        }
    }
}

That is what I want, the total with one call.

But why ES isn't applying the 10.000 limit when I want to scroll anyway ?
Or is there another limit for scrolling ?
What are the drawbacks always using scroll ?

That's exactly what the scroll api is used for.
It is designed to return a much larger or all of your results in a paginated format. Whereas a simple search will stop after 10,000 results (by default) a scroll can return all.
Scrolling essentially paginates your results so that you can create multiple pages of search results.
If you just want to know the number of hits you can use scroll but it is not intended for regular use as it can be quite resource intensive as a scroll search context is saved each time you run it.

I recommend you read up on it here.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.