Querying elastic search triggers exception "Result window is too large"

Hi all,

Is there a method I can call (Java way) to get the default maximum result window constant.

I know it is 10000, and set in the index.max_result_window property (default is 10000).

Just wondering if there is a Java class I can use for getting that value.

And by the way, what is the best way to solve that?

The index.max_result_window is set on the Elasticsearch server side, Hibernate Search has no idea how large it is. So no, you can’t retrieve its value from Hibernate Search.

You might be able to retrieve it from Elasticsearch by querying the settings using the unsupported direct access client provided by Hibernate Search, but I would recommend just setting consistent values in your application and your Elasticsearch cluster.

Just in case, here is the section about this exact topic in the documentation: paging and scrolling. Just a word of advice: if the default value of 10000 is too low for you, you’re very likely to experience performance issues at some point. You should probably change your application to never, ever load that many elements: use scrolling for batch processes, and paging with a reasonably low value, e.g. less than 1000, for displaying results to users.