You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,10 +6,10 @@ This chapter illustrates configuration and usage of supported Elasticsearch clie
6
6
Spring Data Elasticsearch operates upon an Elasticsearch client (provided by Elasticsearch client libraries) that is connected to a single Elasticsearch node or a cluster.
7
7
Although the Elasticsearch Client can be used directly to work with the cluster, applications using Spring Data Elasticsearch normally use the higher level abstractions of xref:elasticsearch/template.adoc[Elasticsearch Operations] and xref:elasticsearch/repositories/elasticsearch-repositories.adoc[Elasticsearch Repositories].
8
8
9
-
[[elasticsearch.clients.restclient]]
10
-
== Imperative Rest Client
9
+
[[elasticsearch.clients.rest5client]]
10
+
== Imperative Rest5Client
11
11
12
-
To use the imperative (non-reactive) client, a configuration bean must be configured like this:
12
+
To use the imperative (non-reactive) Rest5Client, a configuration bean must be configured like this:
13
13
14
14
====
15
15
[source,java]
@@ -31,7 +31,7 @@ public class MyClientConfig extends ElasticsearchConfiguration {
31
31
<.> for a detailed description of the builder methods see xref:elasticsearch/clients.adoc#elasticsearch.clients.configuration[Client Configuration]
32
32
====
33
33
34
-
The javadoc:org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration[]] class allows further configuration by overriding for example the `jsonpMapper()` or `transportOptions()` methods.
34
+
The javadoc:org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration[] class allows further configuration by overriding for example the `jsonpMapper()` or `transportOptions()` methods.
35
35
36
36
37
37
The following beans can then be injected in other Spring components:
<.> an implementation of javadoc:org.springframework.data.elasticsearch.core.ElasticsearchOperations[]
56
+
<.> the `co.elastic.clients.elasticsearch.ElasticsearchClient` that is used.
57
+
<.> the low level `Rest5Client` from the Elasticsearch libraries
58
+
<.> the `JsonpMapper` user by the Elasticsearch `Transport`
59
+
====
60
+
61
+
Basically one should just use the javadoc:org.springframework.data.elasticsearch.core.ElasticsearchOperations[] to interact with the Elasticsearch cluster.
62
+
When using repositories, this instance is used under the hood as well.
63
+
64
+
[[elasticsearch.clients.restclient]]
65
+
== Deprecated Imperative RestClient
66
+
67
+
To use the imperative (non-reactive) RestClient - deprecated since version 6 - , the following dependency needs to be added, adapt the correct version. The exclusion is needed in a Spring Boot application:
public class MyClientConfig extends ElasticsearchLegacyRestClientConfiguration {
95
+
96
+
@Override
97
+
public ClientConfiguration clientConfiguration() {
98
+
return ClientConfiguration.builder() <.>
99
+
.connectedTo("localhost:9200")
100
+
.build();
101
+
}
102
+
}
103
+
----
104
+
105
+
<.> for a detailed description of the builder methods see xref:elasticsearch/clients.adoc#elasticsearch.clients.configuration[Client Configuration]
106
+
====
107
+
108
+
The javadoc:org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration[] class allows further configuration by overriding for example the `jsonpMapper()` or `transportOptions()` methods.
109
+
110
+
111
+
The following beans can then be injected in other Spring components:
Basically one should just use the javadoc:org.springframework.data.elasticsearch.core.ElasticsearchOperations[] to interact with the Elasticsearch cluster.
62
136
When using repositories, this instance is used under the hood as well.
63
137
64
-
[[elasticsearch.clients.reactiverestclient]]
65
-
== Reactive Rest Client
138
+
[[elasticsearch.clients.reactiverest5client]]
139
+
== Reactive Rest5Client
66
140
67
141
When working with the reactive stack, the configuration must be derived from a different class:
<.> an implementation of javadoc:org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations[]
186
+
<.> the `org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient` that is used.
187
+
This is a reactive implementation based on the Elasticsearch client implementation.
188
+
<.> the low level `RestClient` from the Elasticsearch libraries
189
+
<.> the `JsonpMapper` user by the Elasticsearch `Transport`
190
+
====
191
+
192
+
Basically one should just use the javadoc:org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations[] to interact with the Elasticsearch cluster.
193
+
When using repositories, this instance is used under the hood as well.
194
+
195
+
[[elasticsearch.clients.reactiverestclient]]
196
+
== Deprecated Reactive RestClient
197
+
198
+
See the section above for the imperative code to use the deprecated RestClient for the necessary dependencies to include.
199
+
200
+
When working with the reactive stack, the configuration must be derived from a different class:
public class MyClientConfig extends ReactiveElasticsearchLegacyRestClientConfiguration {
209
+
210
+
@Override
211
+
public ClientConfiguration clientConfiguration() {
212
+
return ClientConfiguration.builder() <.>
213
+
.connectedTo("localhost:9200")
214
+
.build();
215
+
}
216
+
}
217
+
----
218
+
219
+
<.> for a detailed description of the builder methods see xref:elasticsearch/clients.adoc#elasticsearch.clients.configuration[Client Configuration]
220
+
====
221
+
222
+
The javadoc:org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchConfiguration[] class allows further configuration by overriding for example the `jsonpMapper()` or `transportOptions()` methods.
223
+
224
+
The following beans can then be injected in other Spring components:
From version 6.0 on, Spring Data Elasticsearch uses the Elasticsearch 9 libraries and as default the new `Rest5Client` provided by these libraries. It is still possible to use the old `RestClient`, check xref:elasticsearch/clients.adoc[Elasticsearch clients] for information. The configuration callbacks for this `RestClient` have been moved from `org.springframework.data.elasticsearch.client.elc.ElasticsearchClients` to the `org.springframework.data.elasticsearch.client.elc.rest_client.RestClients` class.
All the code using the old `RestClient` has been moved to the `org.springframework.data.elasticsearch.client.elc.rest_client` package and has been deprecated. Users should switch to the classes from the `org.springframework.data.elasticsearch.client.elc.rest5_client` package.
0 commit comments