Search Result Limit with Elasticsearch: Mitigating "Result window is too large." errors with index.max_result_window

When searching in a Liferay-Elasticsearch system, a maximum of 10,000 results can be returned by default. If a user attempts to navigate to a results page beyond the maximum results limit, they see a blank page and an exception is logged: "Result window is too large."



You can change the limit by configuring Liferay and Elasticsearch. Make sure you use the same value in both:

  • Liferay: Set the portal property (e.g., in or use the corresponding Docker environment variable, LIFERAY_INDEX_PERIOD_SEARCH_PERIOD_LIMIT
  • Elasticsearch:
    • 7.4 GA/Update 72+: Set Max Result Window in the Elasticsearch 7 configuration in System Settings (or via indexMaxResultWindow="<new-value>")
    • 7.0-7.4:
    • Set Elasticsearch’s index.max_result_window using Liferay’s System Settings using the Additional Index Configurations of the connector configuration.
    • See Elastic’s Dynamic Index Settings for more information on this property including how it can be set on Elasticsearch directly without executing a reindex from Liferay side. 

Returning more results

Allowing more results than 10,000 will degrade performance, but if needed you can increase the maximum result size.

To increase the maximum result size:

  1. Increase in Liferay’s to the desired amount:
  2. Restart Liferay for the setting to be applied.
  3. Configure Elasticsearch’s `index.max_result_window`.

    1. Go to the Control Panel → System Settings → Search → Elasticsearch 7

    2. Set the Max Result Window to the desired amount and save.

    On Liferay versions before 7.4 u72 instead add the configuration under Additional Index Configurations:
    1. Go to the Control Panel → System Settings → Search → Elasticsearch 7
    2. Under Additional Index Configurations, add the following and save:
        "index.max_result_window" : "15000"

  4. After saving the configuration run a full reindex on indexes where the increase is needed.

    Execute re-index the search indexes and spell check indexes from the Index Actions tab of Control Panel → Configuration → Search

    To avoid reindexing, you can apply this setting to Elasticsearch directly by either adding index.max_result_window: 15000 to Elasticsearch’s elasticsearch.yml and restarting the Elasticsearch server, or dynamically through a curl command: 

    curl -XPUT "http://localhost:9200/<index_name>/_settings" -d '{ "index" : { "max_result_window" : "15000" } }' -H "Content-Type: application/json"

    See Elastic’s documentation for more details.

Note: Because of dynamic view permission inheritance, the deepest displayed result may be less than the configured limit if results were removed during post-search permission filtering. Also, Permission Filtered Search Result Accurate Count Threshold and Search Query Result Window Limit maximum values are limited to this setting.

Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0