Fix Elasticsearch error “Result window is too large”

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on tumblr

Table of Contents

The error

In this post, we are solving the following Elasticsearch error:

"Fatal error: Uncaught Elasticsearch\Common\Exceptions\ServerErrorResponseException: {“error”:{“root_cause”:[{“type”:”query_phase_execution_exception”,”reason”:”Result window is too large, from + size must be less than or equal to: [10000] but was [11328]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.”}],”type”:”search_phase_execution_exception”,”reason”:”all shards failed”,”phase”:”query”,”grouped”:true,”failed_shards”:[{“shard”:0,”index”:”xxxxx”,”node”:”xxxxxx”,”reason”:{“type”:”query_phase_execution_exception”,”reason”:”Result window is too large, from + size must be less than or equal to: [10000] but was [11328]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.”}}]},”status”:500} in xxxxxx/public_html/wp-content/plugins/wpsolr-pro/wpsol in /home/185405.cloudwaysapps.com/eyuznfmqse/public_html/wp-content/plugins/wpsolr-pro/wpsolr/core/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 660"

 

The explanation

The error simply means that you tried to show results located after the 10,000th position.

For instance, our WooCommerce The7 demo with 100 thousand products displayed the error after clicking on the last page of results (page 6682, or 100,000th position):

Image wpsolr-the7-theme-window-too-big-error.png of Fix Elasticsearch error

 

Why 10,000?

10,000 is a hard-coded limit in Elasticsearch. This is a default setting, and you’ll need to change it if you want to overcome the problem.

 

The solution

  • Connect to your Elasticsearch server

The demo being on Cloudways, you can ssh to your server as shown below, directly inside your browser. Else, you can ssh by your own means, or even update your settings in Kibana.

Image wpsolr-cloudways-open-ssh-session-in-browser.png of Fix Elasticsearch error

 

  • Find your index name

The settings are related to your index. You need to find your index name, which is stored in WPSOLR.

Image wpsolr-the7-theme-window-too-big-error-index-name.png of Fix Elasticsearch error

 

  • cURL command to change the index settings

curl -X PUT “https://localhost:9200/YOUR_INDEX_NAME_HERE/_settings” -H ‘Content-Type: application/json’ -d ‘{ “index” : { “max_result_window” : YOUR_MAX_RESULTS_HERE } }’

Image wpsolr-the7-theme-window-too-big-error-curl.png of Fix Elasticsearch error

That’s it, nothing to do more, not even restarting Elasticsearch.

The fixed results

Below is the demo with the new settings, able to display the 100,000th results. Nice, is it?

Image wpsolr-the7-theme-window-too-big-error-fixed.png of Fix Elasticsearch error

en English
X