mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-21 03:22:11 +00:00
Update compatibility headers documentation
This commit is contained in:
parent
cf380e289d
commit
453460fab3
@ -154,23 +154,28 @@ If this is used in the reactive setup, the supplier function *must not* block!
|
|||||||
=== Elasticsearch 7 compatibility headers
|
=== 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
|
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].
|
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rest-api-compatibility.html[see Elasticsearch
|
||||||
This should be done using a header supplier like shown above:
|
documentation].
|
||||||
|
|
||||||
|
For the imperative client this must be done by setting the default headers, for the reactive code this must be done using a header supplier:
|
||||||
|
|
||||||
====
|
====
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
ClientConfigurationBuilder configurationBuilder = new ClientConfigurationBuilder();
|
|
||||||
configurationBuilder //
|
HttpHeaders compatibilityHeaders = new HttpHeaders();
|
||||||
// ...
|
compatibilityHeaders.add("Accept", "application/vnd.elasticsearch+json;compatible-with=7");
|
||||||
.withHeaders(() -> {
|
compatibilityHeaders.add("Content-Type", "application/vnd.elasticsearch+json;"
|
||||||
HttpHeaders defaultCompatibilityHeaders = new HttpHeaders();
|
+ "compatible-with=7");
|
||||||
defaultCompatibilityHeaders.add("Accept",
|
|
||||||
"application/vnd.elasticsearch+json;compatible-with=7");
|
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
|
||||||
defaultCompatibilityHeaders.add("Content-Type",
|
.connectedTo("localhost:9200")
|
||||||
"application/vnd.elasticsearch+json;compatible-with=7");
|
.withProxy("localhost:8080")
|
||||||
return defaultCompatibilityHeaders;
|
.withBasicAuth("elastic","hcraescitsale")
|
||||||
});
|
.withDefaultHeaders(compatibilityHeaders) // this variant for imperative code
|
||||||
|
.withHeaders(() -> compatibilityHeaders) // this variant for reactive code
|
||||||
|
.build();
|
||||||
|
|
||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user