From 3cbb89e298eeebcbda74cd6d7d191a3dcb628a1e Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Sat, 8 Nov 2025 18:38:58 +0100 Subject: [PATCH] Update documentation. CLoses #3192 Signed-off-by: Peter-Josef Meisch --- src/main/antora/antora-playbook.yml | 2 +- .../modules/ROOT/pages/elasticsearch.adoc | 2 +- .../ROOT/pages/elasticsearch/clients.adoc | 22 +++++++++++++------ .../ROOT/pages/elasticsearch/misc.adoc | 2 +- .../ROOT/pages/elasticsearch/versions.adoc | 6 ++--- .../ReactiveElasticsearchConfiguration.java | 8 +++---- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/antora/antora-playbook.yml b/src/main/antora/antora-playbook.yml index 1a4f73c1e6..8b5f19b70a 100644 --- a/src/main/antora/antora-playbook.yml +++ b/src/main/antora/antora-playbook.yml @@ -17,7 +17,7 @@ content: - url: https://github.com/spring-projects/spring-data-commons # Refname matching: # https://docs.antora.org/antora/latest/playbook/content-refname-matching/ - branches: [ main, 3.4.x, 3.3.x ] + branches: [ main ] start_path: src/main/antora asciidoc: attributes: diff --git a/src/main/antora/modules/ROOT/pages/elasticsearch.adoc b/src/main/antora/modules/ROOT/pages/elasticsearch.adoc index fe0bddbf20..b55e9705f4 100644 --- a/src/main/antora/modules/ROOT/pages/elasticsearch.adoc +++ b/src/main/antora/modules/ROOT/pages/elasticsearch.adoc @@ -5,7 +5,7 @@ Spring Data support for Elasticsearch contains a wide range of features: * Spring configuration support for various xref:elasticsearch/clients.adoc[Elasticsearch clients]. -* The xref:elasticsearch/template.adoc[`ElasticsearchTemplate` and `ReactiveElasticsearchTemplate`] helper classes that provide object mapping between ES index operations and POJOs. +* The xref:elasticsearch/template.adoc[`ElasticsearchTemplate` and `ReactiveElasticsearchTemplate`] helper classes that provide object mapping between Elasticsearch index operations and POJOs. * xref:elasticsearch/template.adoc#exception-translation[Exception translation] into Spring's portable {springDocsUrl}data-access.html#dao-exceptions[Data Access Exception Hierarchy]. * Feature rich xref:elasticsearch/object-mapping.adoc[object mapping] integrated with _Spring's_ {springDocsUrl}core.html#core-convert[Conversion Service]. * xref:elasticsearch/object-mapping.adoc#elasticsearch.mapping.meta-model.annotations[Annotation-based mapping] metadata that is extensible to support other metadata formats. diff --git a/src/main/antora/modules/ROOT/pages/elasticsearch/clients.adoc b/src/main/antora/modules/ROOT/pages/elasticsearch/clients.adoc index 86354312cc..4df8002002 100644 --- a/src/main/antora/modules/ROOT/pages/elasticsearch/clients.adoc +++ b/src/main/antora/modules/ROOT/pages/elasticsearch/clients.adoc @@ -9,7 +9,7 @@ Although the Elasticsearch Client can be used directly to work with the cluster, [[elasticsearch.clients.rest5client]] == Imperative Rest5Client -To use the imperative (non-reactive) Rest5Client, a configuration bean must be configured like this: +To use the imperative (non-reactive) Rest5Client - the default client provided by the Elasticsearch Java client library from version 9 on -, a configuration bean must be configured like this: ==== [source,java] @@ -39,7 +39,9 @@ The following beans can then be injected in other Spring components: ==== [source,java] ---- -import org.springframework.beans.factory.annotation.Autowired;@Autowired +import org.springframework.beans.factory.annotation.Autowired; + +@Autowired ElasticsearchOperations operations; <.> @Autowired @@ -83,7 +85,7 @@ To use the imperative (non-reactive) RestClient - deprecated since version 6 - , ---- ==== -The configuration bean must be configured like this: +The configuration bean must then be configured like this: ==== [source,java] @@ -113,14 +115,16 @@ The following beans can then be injected in other Spring components: ==== [source,java] ---- -import org.springframework.beans.factory.annotation.Autowired;@Autowired +import org.springframework.beans.factory.annotation.Autowired; + +@Autowired ElasticsearchOperations operations; <.> @Autowired ElasticsearchClient elasticsearchClient; <.> @Autowired -RestClient restClient; <.> +RestClient restClient; <.> @Autowired JsonpMapper jsonpMapper; <.> @@ -167,6 +171,8 @@ The following beans can then be injected in other Spring components: ==== [source,java] ---- +import org.springframework.beans.factory.annotation.Autowired; + @Autowired ReactiveElasticsearchOperations operations; <.> @@ -226,6 +232,8 @@ The following beans can then be injected in other Spring components: ==== [source,java] ---- +import org.springframework.beans.factory.annotation.Autowired; + @Autowired ReactiveElasticsearchOperations operations; <.> @@ -294,7 +302,7 @@ ClientConfiguration clientConfiguration = ClientConfiguration.builder() <.> Define default headers, if they need to be customized <.> Use the builder to provide cluster addresses, set default `HttpHeaders` or enable SSL. -<.> Optionally enable SSL.There exist overloads of this function that can take a `SSLContext` or as an alternative the fingerprint of the certificate as it is output by Elasticsearch 8 on startup. +<.> Optionally enable SSL.There exist overloads of this function that can take a `SSLContext` or as an alternative the fingerprint of the certificate as it is output by Elasticsearch on startup (since version 8). <.> Optionally set a proxy. <.> Optionally set a path prefix, mostly used when different clusters a behind some reverse proxy. <.> Set the connection timeout. @@ -320,7 +328,7 @@ The following callbacks are provided: ==== Configuration of the low level Elasticsearch `Rest5Client`: This callback provides a `org.elasticsearch.client.RestClientBuilder` that can be used to configure the Elasticsearch -`RestClient`: +`Rest5Client`: ==== [source,java] ---- diff --git a/src/main/antora/modules/ROOT/pages/elasticsearch/misc.adoc b/src/main/antora/modules/ROOT/pages/elasticsearch/misc.adoc index 7f3ac8f0ff..9516466a78 100644 --- a/src/main/antora/modules/ROOT/pages/elasticsearch/misc.adoc +++ b/src/main/antora/modules/ROOT/pages/elasticsearch/misc.adoc @@ -11,7 +11,7 @@ When creating Elasticsearch indices with Spring Data Elasticsearch different ind The following arguments are available: * `useServerConfiguration` does not send any settings parameters, so the Elasticsearch server configuration determines them. -* `settingPath` refers to a JSON file defining the settings that must be resolvable in the classpath +* `settingPath` refers to a JSON file defining the settings that must be resolvable in the classpath, it is possible to use a SpEL expression here * `shards` the number of shards to use, defaults to _1_ * `replicas` the number of replicas, defaults to _1_ * `refreshIntervall`, defaults to _"1s"_ diff --git a/src/main/antora/modules/ROOT/pages/elasticsearch/versions.adoc b/src/main/antora/modules/ROOT/pages/elasticsearch/versions.adoc index 96fb56df56..fc37306186 100644 --- a/src/main/antora/modules/ROOT/pages/elasticsearch/versions.adoc +++ b/src/main/antora/modules/ROOT/pages/elasticsearch/versions.adoc @@ -6,10 +6,10 @@ The following table shows the Elasticsearch and Spring versions that are used by [cols="^,^,^,^",options="header"] |=== | Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework -| 2025.1 (in development) | 6.0.x | 9.2.0 | 7.0.x +| 2025.1 | 6.0.x | 9.2.0 | 7.0.x | 2025.0 | 5.5.x | 8.18.1 | 6.2.x -| 2024.1 | 5.4.x | 8.15.5 | 6.1.x -| 2024.0 | 5.3.xfootnote:oom[Out of maintenance] | 8.13.4 | 6.1.x +| 2024.1 | 5.4.xfootnote:oom[Out of maintenance] | 8.15.5 | 6.1.x +| 2024.0 | 5.3.xfootnote:oom[] | 8.13.4 | 6.1.x | 2023.1 (Vaughan) | 5.2.xfootnote:oom[] | 8.11.1 | 6.1.x | 2023.0 (Ullmann) | 5.1.xfootnote:oom[] | 8.7.1 | 6.0.x | 2022.0 (Turing) | 5.0.xfootnote:oom[] | 8.5.3 | 6.0.x diff --git a/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java b/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java index 5449270735..d0198ca9f8 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java @@ -22,11 +22,7 @@ import co.elastic.clients.transport.rest5_client.Rest5ClientOptions; import co.elastic.clients.transport.rest5_client.low_level.RequestOptions; import co.elastic.clients.transport.rest5_client.low_level.Rest5Client; -import co.elastic.clients.transport.rest_client.RestClientOptions; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.elasticsearch.client.RestClient; import org.springframework.context.annotation.Bean; import org.springframework.data.elasticsearch.client.ClientConfiguration; @@ -36,6 +32,10 @@ import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.util.Assert; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + /** * Base class for a @{@link org.springframework.context.annotation.Configuration} class to set up the Elasticsearch * connection using the {@link ReactiveElasticsearchClient}. This class exposes different parts of the setup as Spring