Skip to content

Commit 8285dd0

Browse files
committed
Documentation about compatibility headers.
Original Pull Request #2093 Closes #2088 (cherry picked from commit cf380e2)
1 parent 6f73ac9 commit 8285dd0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/main/asciidoc/reference/elasticsearch-clients.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,29 @@ ClientConfiguration clientConfiguration = ClientConfiguration.builder()
190190

191191
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!
192192

193+
=== Elasticsearch 7 compatibility headers
194+
195+
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
196+
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rest-api-compatibility.html[see Elasticserach documentation].
197+
This should be done using a header supplier like shown above:
198+
199+
====
200+
[source,java]
201+
----
202+
ClientConfigurationBuilder configurationBuilder = new ClientConfigurationBuilder();
203+
configurationBuilder //
204+
// ...
205+
.withHeaders(() -> {
206+
HttpHeaders defaultCompatibilityHeaders = new HttpHeaders();
207+
defaultCompatibilityHeaders.add("Accept",
208+
"application/vnd.elasticsearch+json;compatible-with=7");
209+
defaultCompatibilityHeaders.add("Content-Type",
210+
"application/vnd.elasticsearch+json;compatible-with=7");
211+
return defaultCompatibilityHeaders;
212+
});
213+
----
214+
====
215+
193216
[[elasticsearch.clients.logging]]
194217
== Client Logging
195218

0 commit comments

Comments
 (0)