Skip to content

Commit 5b02364

Browse files
authored
Remove deprecated code.
Original Pull Request #2564 Closes #2563
1 parent 34b0181 commit 5b02364

17 files changed

+26
-1089
lines changed

CONTRIBUTING.adoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@ Do not submit a Pull Request before having created an issue and having discussed
88
== Running the test locally
99

1010
In order to run the tests locally with `./mvnw test` you need to have docker running because Spring Data Elasticsearch uses https://www.testcontainers.org/[Testcontainers] to start a local running Elasticsearch instance.
11-
12-
== Class names of the test classes
13-
14-
Test classes that do depend on the client have either `ERHLC` (when using the deprecated Elasticsearch `RestHighLevelClient`) or `ELC` (the new `ElasticsearchClient`) in their name.

README.adoc

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,20 @@ image:https://spring.io/badges/spring-data-elasticsearch/ga.svg[Spring Data Elas
55
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
66

77
The Spring Data Elasticsearch project provides integration with the https://www.elastic.co/[Elasticsearch] search engine.
8-
Key functional areas of Spring Data Elasticsearch are a POJO centric model for interacting with a Elasticsearch Documents and easily writing a Repository style data access layer.
8+
Key functional areas of Spring Data Elasticsearch are a POJO centric model for interacting with Elasticsearch Documents and easily writing a Repository style data access layer.
99

1010
This project is lead and maintained by the community.
1111

1212
== Features
1313

14-
* Spring configuration support using Java based `@Configuration` classes or an XML namespace for a ES clients instances.
14+
* Spring configuration support using Java based `@Configuration` classes or an XML namespace for an ES client instances.
1515
* `ElasticsearchOperations` class and implementations that increases productivity performing common ES operations.
1616
Includes integrated object mapping between documents and POJOs.
1717
* Feature Rich Object Mapping integrated with Spring’s Conversion Service
1818
* Annotation based mapping metadata
1919
* Automatic implementation of `Repository` interfaces including support for custom search methods.
2020
* CDI support for repositories
2121

22-
== About Elasticsearch versions and clients
23-
24-
=== Elasticsearch 7.17 client libraries
25-
26-
At the end of 2021 Elasticsearch with version 7.17 released the new version of their Java client and deprecated the `RestHighLevelCLient` which was the default way to access Elasticsearch up to then.
27-
28-
Spring Data Elasticsearch will in version 4.4 offer the possibility to optionally use the new client as an alternative to the existing setup using the `RestHighLevelCLient`.
29-
The default client that is used still is the `RestHighLevelCLient`, first because the integration of the new client is not yet complete, the new client still has features missing and bugs which will hopefully be resolved soon.
30-
Second, and more important, the new Elasticsearch client forces users to switch from using `javax.json.spi.JsonProvider` to `jakarta.json.spi.JsonProvider`.
31-
Spring Data Elasticsearch cannot enforce this switch; Spring Boot will switch to `jakarta` with version 3 and then it's safe for Spring Data Elasticsearch to switch to the new client.
32-
33-
So for version 4.4 Spring Data Elasticsearch will keep using the `RestHighLevelCLient` in version 7.17.x (as long as this will be available).
34-
35-
=== Elasticsearch 8 client libraries
36-
37-
In Elasticsearch 8, the `RestHighLevelCLient` has been removed.
38-
This means that a switch to this client version can only be done with the next major upgrade which will be Spring Data Elasticsearch 5, based on Spring Data 3, used by Spring Boot 3, based on Spring 6 and Java 17.
39-
40-
=== Elasticsearch 8 cluster
41-
42-
It should be possible to use the Elasticsearch 7 client to access a cluster running version 8 by setting the appropriate compatibility headers (see the documentation at https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.configuration). but I encountered and heard of cases where the response from the server is not parseable by the client although the headers are set, so use with care.
43-
4422
== Code of Conduct
4523

4624
This project is governed by the https://github.com/spring-projects/.github/blob/e3cc2ff230d8f1dca06535aa6b5a4a23815861d4/CODE_OF_CONDUCT.md[Spring Code of Conduct].
@@ -86,25 +64,7 @@ public class MyService {
8664

8765
=== Using the RestClient
8866

89-
Provide a configuration like this:
90-
91-
[source,java]
92-
----
93-
@Configuration
94-
public class RestClientConfig extends AbstractElasticsearchConfiguration {
95-
96-
@Override
97-
@Bean
98-
public RestHighLevelClient elasticsearchClient() {
99-
100-
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
101-
.connectedTo("localhost:9200")
102-
.build();
103-
104-
return RestClients.create(clientConfiguration).rest();
105-
}
106-
}
107-
----
67+
Please check the [official documentation](https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.configuration).
10868

10969
=== Maven configuration
11070

@@ -119,9 +79,6 @@ Add the Maven dependency:
11979
</dependency>
12080
----
12181

122-
// NOTE: since Github does not support include directives, the content of
123-
// the src/main/asciidoc/reference/preface.adoc file is duplicated here
124-
// Always change both files!
12582
**Compatibility Matrix**
12683

12784
The compatibility between Spring Data Elasticsearch, Elasticsearch client drivers and Spring Boot versions can be found in the https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.versions[reference documentation].

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

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -105,98 +105,6 @@ This is a reactive implementation based on the Elasticsearch client implementati
105105
Basically one should just use the `ReactiveElasticsearchOperations` to interact with the Elasticsearch cluster.
106106
When using repositories, this instance is used under the hood as well.
107107

108-
[[elasticsearch.clients.resthighlevelclient]]
109-
== High Level REST Client (deprecated)
110-
111-
[CAUTION]
112-
====
113-
The Elasticsearch Java RestHighLevelClient is deprecated, but still can be configured like shown (make sure to read
114-
<<elasticsearch-migration-guide-4.4-5.0.old-client>> as well).
115-
116-
It should only be used to access an Elasticsearch cluster running version 7, even with the compatibility headers set
117-
there are cases where the `RestHighLevelClient` cannot read the responses sent from a version 8 cluster.
118-
====
119-
120-
.RestHighLevelClient
121-
====
122-
[source,java]
123-
----
124-
import org.springframework.data.elasticsearch.client.erhlc.AbstractElasticsearchConfiguration;
125-
126-
@Configuration
127-
public class RestClientConfig extends AbstractElasticsearchConfiguration {
128-
129-
@Override
130-
@Bean
131-
public RestHighLevelClient elasticsearchClient() {
132-
133-
final ClientConfiguration clientConfiguration = ClientConfiguration.builder() <1>
134-
.connectedTo("localhost:9200")
135-
.build();
136-
137-
return RestClients.create(clientConfiguration).rest(); <2>
138-
}
139-
}
140-
141-
// ...
142-
143-
@Autowired
144-
RestHighLevelClient highLevelClient;
145-
146-
RestClient lowLevelClient = highLevelClient.lowLevelClient(); <3>
147-
----
148-
149-
<1> Use the builder to provide cluster addresses, set default `HttpHeaders` or enable SSL.
150-
<2> Create the RestHighLevelClient.
151-
<3> It is also possible to obtain the `lowLevelRest()` client.
152-
====
153-
154-
[[elasticsearch.clients.reactive]]
155-
== Reactive Client (deprecated)
156-
157-
The `org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient` is a non official driver based on `WebClient`.
158-
It uses the request/response objects provided by the Elasticsearch core project.
159-
Calls are directly operated on the reactive stack, **not** wrapping async (thread pool bound) responses into reactive types.
160-
161-
[CAUTION]
162-
====
163-
This was the first reactive implementation Spring Data Elasticsearch provided, but now is deprecated in favour
164-
of the `org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient`
165-
which uses the functionality offered by the new Elasticsearch client libraries.
166-
====
167-
168-
.Reactive REST Client (deprecated)
169-
====
170-
[source,java]
171-
----
172-
import org.springframework.data.elasticsearch.client.erhlc.AbstractReactiveElasticsearchConfiguration;
173-
174-
@Configuration
175-
public class ReactiveRestClientConfig extends AbstractReactiveElasticsearchConfiguration {
176-
177-
@Override
178-
@Bean
179-
public ReactiveElasticsearchClient reactiveElasticsearchClient() {
180-
final ClientConfiguration clientConfiguration = ClientConfiguration.builder() <.>
181-
.connectedTo("localhost:9200") //
182-
.build();
183-
return ReactiveRestClients.create(clientConfiguration);
184-
185-
}
186-
}
187-
// ...
188-
189-
Mono<IndexResponse> response = client.index(request ->
190-
191-
request.index("spring-data")
192-
.id(randomID())
193-
.source(singletonMap("feature", "reactive-client"));
194-
);
195-
----
196-
197-
<.> Use the builder to provide cluster addresses, set default `HttpHeaders` or enable SSL.
198-
====
199-
200108
[[elasticsearch.clients.configuration]]
201109
== Client Configuration
202110

@@ -298,38 +206,6 @@ ClientConfiguration.builder()
298206
----
299207
====
300208

301-
[[elasticsearch.clients.configuration.headers]]
302-
=== Elasticsearch 7 compatibility headers
303-
304-
When using the deprecated `RestHighLevelClient` and accessing an Elasticsearch cluster that is running on version 8, it is necessary to set the compatibility headers
305-
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/rest-api-compatibility.html[see Elasticsearch
306-
documentation].
307-
308-
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:
309-
310-
CAUTION: Even when these headers are set, there are cases where the response returned from the cluster cannot be
311-
parsed with the client. This is not an error in Spring Data Elasticsearch.
312-
313-
====
314-
[source,java]
315-
----
316-
317-
HttpHeaders compatibilityHeaders = new HttpHeaders();
318-
compatibilityHeaders.add("Accept", "application/vnd.elasticsearch+json;compatible-with=7");
319-
compatibilityHeaders.add("Content-Type", "application/vnd.elasticsearch+json;"
320-
+ "compatible-with=7");
321-
322-
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
323-
.connectedTo("localhost:9200")
324-
.withProxy("localhost:8080")
325-
.withBasicAuth("elastic","hcraescitsale")
326-
.withDefaultHeaders(compatibilityHeaders) // this variant for imperative code
327-
.withHeaders(() -> compatibilityHeaders) // this variant for reactive code
328-
.build();
329-
330-
----
331-
====
332-
333209
[[elasticsearch.clients.logging]]
334210
== Client Logging
335211

src/main/asciidoc/reference/elasticsearch-migration-guide-5.1-5.2.adoc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ This section describes breaking changes from version 5.1.x to 5.2.x and how remo
66
[[elasticsearch-migration-guide-5.1-5.2.breaking-changes]]
77
== Breaking Changes
88

9-
109
[[elasticsearch-migration-guide-5.1-5.2.deprecations]]
1110
== Deprecations
11+
12+
=== Removal of deprecated code
13+
14+
* All the code using the old deprecated `RestHighLevelClient` has been removed.
15+
The default Elasticsearch client used since version 5.0 is the (not so) new Elasticsearch Java client.
16+
* The `org.springframework.data.elasticsearch.client.ClientLogger` class has been removed.
17+
This logger was configured with the `org.springframework.data.elasticsearch.client.WIRE` setting, but was not working with all clients.
18+
From version 5 on, use the trace logger available in the Elasticsearch Java client, see <<elasticsearch.clients.logging>>.
19+
* The method `org.springframework.data.elasticsearch.core.ElasticsearchOperations.stringIdRepresentation(Object)` has been removed, use the `convertId(Object)` method defined in the same interface instead.
20+
* The class `org.springframework.data.elasticsearch.core.Range` has been removed, use `org.springframework.data.domain.Range` instead.
21+
* The methods `org.springframework.data.elasticsearch.core.query.IndexQuery.getParentId() and `setParentId(String)` have been removed, they werent used anymore and were no-ops. It has been removed from the `org.springframework.data.elasticsearch.core.query.IndexQuery` class as well.

src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class ClientConfigurationBuilder
5959
@Nullable private String pathPrefix;
6060
@Nullable private String proxy;
6161
private Supplier<HttpHeaders> headersSupplier = HttpHeaders::new;
62-
@Deprecated private final HttpClientConfigCallback httpClientConfigurer = httpClientBuilder -> httpClientBuilder;
6362
private final List<ClientConfiguration.ClientConfigurationCallback<?>> clientConfigurers = new ArrayList<>();
6463

6564
/*
@@ -242,7 +241,7 @@ public ClientConfiguration build() {
242241
}
243242

244243
return new DefaultClientConfiguration(hosts, headers, useSsl, sslContext, caFingerprint, soTimeout, connectTimeout,
245-
pathPrefix, hostnameVerifier, proxy, httpClientConfigurer, clientConfigurers, headersSupplier);
244+
pathPrefix, hostnameVerifier, proxy, clientConfigurers, headersSupplier);
246245
}
247246

248247
private static InetSocketAddress parse(String hostAndPort) {

0 commit comments

Comments
 (0)