Home > Net >  How to set max_result_window on hibernate search for elasticsearch backend
How to set max_result_window on hibernate search for elasticsearch backend

Time:09-29

We have an existing spring boot, hibernate search, elasticsearch production system that works day to day with index results under the 10,000 default. Once a month I run a report on a local environment where the index results are sometimes between 30,000 and 40,000

On elasticsearch 5 and hibernate 5 this was accommodated by modifying index.max_result_window on the index to 100,000. Now I have moved to hibernate 6, hibernate search 6.1.7 and elasticsearch 7.16 this solution no longer works, resulting in a validation error at startup.

Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:

    Hibernate ORM mapping: 
        type 'blahh.blahh.Blahh': 
            failures: 
              - Validation of the existing index in the Elasticsearch cluster failed. See below for details.
            attribute 'max_result_window': 
                failures: Invalid value. Expected '10000', actual is '100000'

So I assume from the error that hibernate search sees the new value on the elasticsearch index but that it does not correspond with a 10,000 it has, I guess, on the code side. But where that is I don’t know.

The documentation seems to still suggest the solution I’m using has not changed. And I can’t find anything to suggest there is something I can set on the code to match the elasticsearch index value.

Also changing the setting after hibernate startup does not help, the max size is still 10k.

I realise that there are solutions to change the code but as it only runs once a month locally there is immeasurable resistance to change the main system for this.

Thanks

CodePudding user response:

Just use custom index settings to let Hibernate Search know you expect this setting to be customized:

hibernate.search.backend.schema_management.settings_file = custom/index-settings.json

src/main/resources/mysettings.json:

{
  "max_result_window": 100000
}

See also https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-elasticsearch-configuration-index-settings-max-result-window-size

  • Related