gpt4 book ai didi

java - hibernate 搜索配置

转载 作者:行者123 更新时间:2023-12-01 16:28:19 24 4
gpt4 key购买 nike

我使用 hibernate search 和 elastic search 作为后端。当我在 xml 文件中配置 hibernate 和 hibernatesearch 时,一切正常,但是当我在 java 类中配置它时,会出现此警告,并且在我的搜索中找不到任何内容。xml配置是:

<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3399/elastic" />
<property name="hibernate.connection.username" value="admin" />
<property name="hibernate.connection.password" value="admin" />

<property name="hibernate.show_sql" value="true" />

<property name="hibernate.search.default.indexmanager" value="elasticsearch"/>
<property name="hibernate.search.default.elasticsearch.host" value="http://127.0.0.1:9400"/>
<property name="hibernate.search.default.elasticsearch.index_schema_management_strategy" value="CREATE"/>
<property name="hibernate.search.default.elasticsearch.required_index_status" value="YELLOW"/>

</properties>

java类配置是:

java.util.Properties settings = new java.util.Properties();
settings.put(org.hibernate.cfg.Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
settings.put(org.hibernate.cfg.Environment.URL, "jdbc:mysql://127.0.0.1:3399/elastic");
settings.put(org.hibernate.cfg.Environment.USER, "admin");
settings.put(org.hibernate.cfg.Environment.PASS, "admin");
settings.put(org.hibernate.cfg.Environment.DIALECT,"org.hibernate.dialect.MySQL8Dialect");
settings.put(org.hibernate.cfg.Environment.SHOW_SQL, "true");
settings.put(org.hibernate.cfg.Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
settings.put(org.hibernate.cfg.Environment.POOL_SIZE, "5");
settings.put("hibernate.search.default.indexmanager", "elasticsearch");
settings.put("hibernate.search.default.elasticsearch.host", "http://127.0.0.1:9400");
settings.put("hibernate.search.default.elasticsearch.index_schema_management_strategy", "CREATE");
settings.put("hibernate.search.default.elasticsearch.required_index_status", "YELLOW");

警告是:

WARNING: request [HEAD http://127.0.0.1:9400/com.radar.elasticsearch.videogame] returned 1 warnings: [299 Elasticsearch-6.8.0-65b6179 "[types removal] The parameter include_type_name should be explicitly specified in get indices requests to prepare for 7.0. In 7.0 include_type_name will default to 'false', which means responses will omit the type name in mapping definitions."]

最佳答案

您使用的是 Elasticsearch 6.8,其中 types 已弃用。请引用removal of types欲了解更多信息,

您需要传递 _doc 而不是类型名称,否则如果您在所有 API 中使用自己的 type 名称,则使用 include_type_name

请引用this官方博客了解更多信息

If you plan to upgrade without downtime in a rolling fashion, you should upgrade to 6.8 first, which is the only 6.x release to have some features like support for the include_type_name parameter, which is required to upgrade to 7.0 smoothly.

关于java - hibernate 搜索配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62115858/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com