Search Result Limit with Elasticsearch

When searching in a Liferay-Elasticsearch system, a maximum of 10,000 results are 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."

 

Resolution

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

  • Liferay: Set the index.search.limit portal property (e.g., in portal-ext.properties) or use the corresponding Docker environment variable, LIFERAY_INDEX_PERIOD_SEARCH_PERIOD_LIMIT. 
  • Elasticsearch: Set Elasticsearch’s index.max_result_window using Liferay’s System Settings. See Elastic’s Dynamic Index Settings for more information on this property. 

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 index.search.limit in Liferay’s portal-ext.properties to the desired amount:
    index.search.limit=15000
  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 Inheritance Permissioning, 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