Hibernate search elasticsearch 模式管理 NONE 仍然连接到 elasticsearch?

Hibernate search elasticsearch schema management NONE still connects to elasticsearch?

我正在考虑将我们的休眠搜索实现从基于文件的 lucene 索引转移到 elasticsearch,但对文档感到困惑。具体来说,对于索引架构管理策略NONE:

The index, its mappings and the analyzer definitions will not be created, deleted nor altered. Hibernate Search will not even check that the index already exists.

我们想移除 hibernate search 的启动依赖(这样它就不会在启动时尝试查询 elasticsearch)。阅读架构管理策略表明 NONE 应该这样做。

但是,查看代码的实现,我可以看到它仍然显式检查索引是否存在:

if (this.schemaManagementStrategy == IndexSchemaManagementStrategy.NONE) {
    this.schemaCreator.checkIndexExists(this.actualIndexName, this.schemaManagementExecutionOptions);
    return false;
}

我本以为这不会发生。当我故意输入不正确的主机进行连接时,服务器启动仍然失败并显示:

 Request:
========
Operation: IndicesExists
URI: registryreference
Data:
null
Response:
=========
null
    at org.hibernate.search.elasticsearch.client.impl.JestClient.executeRequest(JestClient.java:188) ~[hibernate-search-elasticsearch-5.6.5.Final.jar:5.6.5.Final]
... (omitted rest of stack) 
Caused by: java.net.ConnectException: Connection refused: connect

我们正在使用 hibernate search 5.6.5 和 elasticsearch 2.4.6。

这是一个错误:HSEARCH-2568

它已在 Hibernate Search 5.7 中修复。0.Final,因此升级应该可以解决问题。不过,您还必须将 Hibernate ORM 升级到版本 5.2。如果你走这条路,我建议直接升级到 Hibernate Search 5.11 和 ORM 5.4,这是修复了很多错误的最新版本。

请注意,正如@Sanne 提到的,即使 Hibernate Search 不向 Elasticsearch 集群发送查询,它仍可能创建一个 TCP 连接池。也许您可以告诉我们更多有关您的用例的信息,以便我们提供帮助?