Is it always necessary to use size attribute in DSL query?


Is it always necessary to use the size attribute in Elasticsearch DSL query?

What if there are many documents and I do not know the exact no of documents that I would need?

I am trying to get the last poll data from Elasticsearch. In the last poll (time < now-5m), I get large no of docs, sometimes > 10,000. So how do I get the data without having to specify the size?


It depends on what you want to do but the answer is no.

It will tell you how many docs you have and will return the first 10 by default.

You can use:

  • the size and from parameters to display by default up to 10000 records to your users. If you want to change this limit, you can change index.max_result_window setting but be aware of the consequences (ie memory).
  • the search after feature to do deep pagination.
  • the Scroll API if you want to extract a resultset to be consumed by another tool later. (Not recommended anymore)
1 Like


Thanks for the reply.

So if I go for the first approach, using size and from parameter, let's say I have to display the results in a table. Then each time the user changes the page number or clicks on next page button, a search query with the corresponding size and from values should be sent to Elasticsearch?



1 Like

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