WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
The Java High Level REST Client requires at least Java 1.8 and depends on the Elasticsearch
core project. The client version is the same as the Elasticsearch version that the
client was developed for. It accepts the same request arguments as the
and returns the same response objects. See the Migration Guide
if you need to migrate an application from
TransportClient to the new REST client.
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 7.0 client is able to communicate with any 7.x Elasticsearch node, while the 7.1 client is for sure able to communicate with 7.1, 7.2 and any later 7.x version, but there may be incompatibility issues when communicating with a previous Elasticsearch node version, for instance between 7.1 and 7.0, in case the 7.1 client supports new request body fields for some APIs that are not known by the 7.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. The client should always be updated last, once all of the nodes in the cluster have been upgraded to the new major version.
Compatibility with Elasticsearch 8.x
The High Level Client version 7.16 and higher can communicate with Elasticsearch version 8.x after enabling API compatibility mode. When this mode is enabled, the client will send HTTP headers that instruct Elasticsearch 8.x to honor 7.x request/responses.
Compatibility mode is enabled as follows:
RestHighLevelClient esClient = new RestHighLevelClientBuilder(restClient) .setApiCompatibilityMode(true) .build()
When compatibility mode is enabled, the client can also communicate with Elasticsearch version 7.11 and higher.