简体   繁体   English

如何在 hibernate 上设置 max_result_window 搜索 elasticsearch 后端

[英]How to set max_result_window on hibernate search for elasticsearch backend

We have an existing spring boot, hibernate search, elasticsearch production system that works day to day with index results under the 10,000 default.我们有一个现有的 spring 启动、hibernate 搜索、elasticsearch 生产系统,该系统每天都在默认情况下使用 10,000 索引结果。 Once a month I run a report on a local environment where the index results are sometimes between 30,000 and 40,000我每月运行一次关于本地环境的报告,其中的索引结果有时在 30,000 到 40,000 之间

On elasticsearch 5 and hibernate 5 this was accommodated by modifying index.max_result_window on the index to 100,000.在 elasticsearch 5 和 hibernate 5 上,这是通过将索引上的 index.max_result_window 修改为 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.现在我已经转移到hibernate 6、hibernate搜索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'

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.因此,我从错误中假设 hibernate 搜索在 elasticsearch 索引上看到了新值,但我猜它与代码端的 10,000 不对应。 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.而且我找不到任何建议我可以在代码上设置一些东西来匹配 elasticsearch 索引值。

Also changing the setting after hibernate startup does not help, the max size is still 10k.在 hibernate 启动后更改设置也无济于事,最大大小仍然是 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谢谢

Just use custom index settings to let Hibernate Search know you expect this setting to be customized:只需使用自定义索引设置让 Hibernate 搜索知道您希望自定义此设置:

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

src/main/resources/custom/index-settings.json : src/main/resources/custom/index-settings.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另见https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#backend-elasticsearch-configuration-index-settings-max-result-window-size

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM