Documentation about compatibility headers.

Original Pull Request #2093
Closes #2088

(cherry picked from commit cf380e289d4e01c220c6a7fc0484e46ab959ac94)
This commit is contained in:
Peter-Josef Meisch 2022-02-18 20:53:42 +01:00
parent 6f73ac952b
commit 8285dd0cd0
No known key found for this signature in database
GPG Key ID: DE108246970C7708

View File

@ -190,6 +190,29 @@ ClientConfiguration clientConfiguration = ClientConfiguration.builder()
IMPORTANT: Adding a Header supplier as shown in above example allows to inject headers that may change over the time, like authentication JWT tokens. If this is used in the reactive setup, the supplier function *must not* block!
=== Elasticsearch 7 compatibility headers
When using Spring Data Elasticsearch 4 - which uses the Elasticsearch 7 client libraries - and accessing an Elasticsearch cluster that is running on version 8, it is necessary to set the compatibility headers
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rest-api-compatibility.html[see Elasticserach documentation].
This should be done using a header supplier like shown above:
====
[source,java]
----
ClientConfigurationBuilder configurationBuilder = new ClientConfigurationBuilder();
configurationBuilder //
// ...
.withHeaders(() -> {
HttpHeaders defaultCompatibilityHeaders = new HttpHeaders();
defaultCompatibilityHeaders.add("Accept",
"application/vnd.elasticsearch+json;compatible-with=7");
defaultCompatibilityHeaders.add("Content-Type",
"application/vnd.elasticsearch+json;compatible-with=7");
return defaultCompatibilityHeaders;
});
----
====
[[elasticsearch.clients.logging]]
== Client Logging