如何在ElasticSearch后端的Hibernate搜索中设置max_result_window

6qfn3psc  于 2022-11-02  发布在  ElasticSearch
关注(0)|答案(1)|浏览(164)

我们有一个现有的spring boot、hibsearch、elasticsearch生产系统,它每天都在默认的10,000个索引结果下工作。
在elasticsearch 5和hib5中,通过将index上的index.max_result_window修改为100,000来解决这个问题。现在,我已经转到了hib6、hibsearch 6.1.7和elasticsearch 7.16,这个解决方案不再起作用,导致启动时出现验证错误。

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'

所以我从这个错误中假设,Hibernate搜索在elasticsearch索引上看到了新的值,但是我猜,它在代码端没有对应的10,000,但是我不知道它在哪里。
文档似乎仍然暗示我使用的解决方案没有改变。而且我找不到任何东西来暗示我可以在代码上设置一些东西来匹配elasticsearch索引值。
此外,在休眠启动后更改设置也没有帮助,最大大小仍然是10K。
我意识到,有解决方案来改变代码,但由于它只运行一个月一次,在本地有不可估量的阻力,以改变主系统为此。
谢谢

dfuffjeb

dfuffjeb1#

只需使用自定义索引设置,即可让Hibernate搜索知道您希望自定义此设置:

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

src/main/resources/custom/index-settings.json

{
  "max_result_window": 100000
}

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

相关问题