是否有关于 java elasticsearch 库和 es 发行版之间兼容性的信息?

Is there an info on compatibility beween java elasticsearch libs and es distros?

我找过这个但是没有成功。我找到的所有内容都是 this, which doesn't contain any information about compatibility with version of java es libs.

这取决于你所说的“客户”是什么意思。

历史JavaAPI

否则命名为“Java API”,或“传输客户端”。这个客户端从最早的版本就存在了。 您可以在 documentation 上阅读:

The TransportClient is deprecated in favour of the Java High Level REST Client and will be removed in Elasticsearch 8.0. The migration guide describes all the steps needed to migrate.

按照迁移指南,您最终会到达 this page(强调我的):

Motivations around a new Java client

The existing TransportClient has been part of Elasticsearch since its very first commit. It is a special client as it uses the transport protocol to communicate with Elasticsearch, which causes compatibility problems if the client is not on the same version as the Elasticsearch instances it talks to.

结论:Java API 客户端需要遵循服务器的版本。

Java 低级别客户端

Introduced in 2016 with ES 5.0,低级客户端实际上只是一个美化的原始 HTTP 客户端,带有一些可以更好地集成到 ES 的技巧。

The first release only included what we call a low-level client, which has the following features:

  • compatibility with any Elasticsearch version
  • load balancing across all available nodes
  • failover in case of node failures and upon specific response codes
  • failed connection penalization
  • persistent connections
  • trace logging of requests and responses
  • optional automatic discovery of cluster nodes (also known as sniffing)

因为它只真正处理 HTTP 级的东西,低级客户端兼容所有版本。另一方面,它对您 write/format JSON SearchDSL 查询或管理查询没有帮助,为此,您需要...高级客户端。

It is called the low-level client because it does little to help the Java users to build requests or to parse responses. It handles path and query-string construction for requests, but it treats JSON request and response bodies as opaque byte arrays which have to be handled by the user.

The next step is releasing a high level client that accepts proper request objects, takes care of their marshalling, and returns parsed response objects.

Java 高级客户

高级客户有 compatibility page

长话短说:您应该使用至少与集群版本相同的版本。滞后次要版本通常没问题,但不是预期的。落后于主要版本可能不起作用,因为主要版本可能会引入 API 更改。

The High Level Client is guaranteed to be able to communicate with any Elasticsearch node running on the same major version and greater or equal minor version. It doesn’t need to be in the same minor version as the Elasticsearch nodes it communicates with, as it is forward compatible meaning that it supports communicating with later versions of Elasticsearch than the one it was developed for.

The 6.0 client is able to communicate with any 6.x Elasticsearch node, while the 6.1 client is for sure able to communicate with 6.1, 6.2 and any later 6.x version, but there may be incompatibility issues when communicating with a previous Elasticsearch node version, for instance between 6.1 and 6.0, in case the 6.1 client supports new request body fields for some APIs that are not known by the 6.0 node(s).

It is recommended to upgrade the High Level Client when upgrading the Elasticsearch cluster to a new major version, as REST API breaking changes may cause unexpected results depending on the node that is hit by the request, and newly added APIs will only be supported by the newer version of the client.