Skip to content

Commit 412a2e2

Browse files
authored
Upgrade to Elasticsearch 8.9.0.
Original Pull Request #2656 Closes #2650
1 parent bd71a93 commit 412a2e2

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<springdata.commons>3.2.0-SNAPSHOT</springdata.commons>
2222

2323
<!-- version of the ElasticsearchClient -->
24-
<elasticsearch-java>8.8.2</elasticsearch-java>
24+
<elasticsearch-java>8.9.0</elasticsearch-java>
2525

2626
<blockhound-junit>1.0.8.RELEASE</blockhound-junit>
2727
<hoverfly>0.14.4</hoverfly>

src/main/asciidoc/preface.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ built and tested.
3737
[cols="^,^,^,^,^",options="header"]
3838
|===
3939
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot
40-
| 2023.1 (Vaughan) | 5.2.x | 8.8.2 | 6.0.x | 3.1.x
40+
| 2023.1 (Vaughan) | 5.2.x | 8.9.0 | 6.0.x | 3.1.x
4141
| 2023.0 (Ullmann) | 5.1.x | 8.7.1 | 6.0.x | 3.1.x
4242
| 2022.0 (Turing) | 5.0.x | 8.5.3 | 6.0.x | 3.0.x
4343
| 2021.2 (Raj) | 4.4.xfootnote:oom[Out of maintenance] | 7.17.3 | 5.3.x | 2.7.x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[[new-features.5-2-0]]
55
== New in Spring Data Elasticsearch 5.2
66

7-
* Upgrade to Elasticsearch 8.8.2
7+
* Upgrade to Elasticsearch 8.9.0
88
* The `JsonpMapper` for Elasticsearch is now configurable and provided as bean.
99
* Improved AOT runtime hints for Elasticsearch client library classes.
1010
* Add Kotlin extensions and repository coroutine support.

src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
import java.util.function.Supplier;
3535
import java.util.stream.Collectors;
3636

37-
import org.apache.http.*;
37+
import org.apache.http.HttpHost;
38+
import org.apache.http.HttpRequest;
39+
import org.apache.http.HttpRequestInterceptor;
3840
import org.apache.http.client.config.RequestConfig;
3941
import org.apache.http.entity.ContentType;
4042
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
@@ -261,26 +263,44 @@ private static ElasticsearchTransport getElasticsearchTransport(RestClient restC
261263
TransportOptions.Builder transportOptionsBuilder = transportOptions != null ? transportOptions.toBuilder()
262264
: new RestClientOptions(RequestOptions.DEFAULT).toBuilder();
263265

266+
RestClientOptions.Builder restClientOptionsBuilder = getRestClientOptionsBuilder(transportOptions);
267+
264268
ContentType jsonContentType = Version.VERSION == null ? ContentType.APPLICATION_JSON
265269
: ContentType.create("application/vnd.elasticsearch+json",
266270
new BasicNameValuePair("compatible-with", String.valueOf(Version.VERSION.major())));
267271

268272
Consumer<String> setHeaderIfNotPresent = header -> {
269-
if (transportOptionsBuilder.build().headers().stream() //
273+
if (restClientOptionsBuilder.build().headers().stream() //
270274
.noneMatch((h) -> h.getKey().equalsIgnoreCase(header))) {
271275
// need to add the compatibility header, this is only done automatically when not passing in custom options.
272276
// code copied from RestClientTransport as it is not available outside the package
273-
transportOptionsBuilder.addHeader(header, jsonContentType.toString());
277+
restClientOptionsBuilder.addHeader(header, jsonContentType.toString());
274278
}
275279
};
276-
280+
§
277281
setHeaderIfNotPresent.accept("Content-Type");
278282
setHeaderIfNotPresent.accept("Accept");
279283

280-
TransportOptions transportOptionsWithHeader = transportOptionsBuilder
281-
.addHeader(X_SPRING_DATA_ELASTICSEARCH_CLIENT, clientType).build();
284+
restClientOptionsBuilder.addHeader(X_SPRING_DATA_ELASTICSEARCH_CLIENT, clientType);
285+
286+
return new RestClientTransport(restClient, jsonpMapper, restClientOptionsBuilder.build());
287+
}
288+
289+
private static RestClientOptions.Builder getRestClientOptionsBuilder(@Nullable TransportOptions transportOptions) {
282290

283-
return new RestClientTransport(restClient, jsonpMapper, transportOptionsWithHeader);
291+
if (transportOptions instanceof RestClientOptions restClientOptions) {
292+
return restClientOptions.toBuilder();
293+
}
294+
295+
var builder = new RestClientOptions.Builder(RequestOptions.DEFAULT.toBuilder());
296+
297+
if (transportOptions != null) {
298+
transportOptions.headers().forEach(header -> builder.addHeader(header.getKey(), header.getValue()));
299+
transportOptions.queryParameters().forEach(builder::setParameter);
300+
builder.onWarnings(transportOptions.onWarnings());
301+
}
302+
303+
return builder;
284304
}
285305

286306
private static List<String> formattedHosts(List<InetSocketAddress> hosts, boolean useSsl) {

src/test/resources/testcontainers-elasticsearch.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
#
1717
sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch
18-
sde.testcontainers.image-version=8.8.2
18+
sde.testcontainers.image-version=8.9.0
1919
#
2020
#
2121
# needed as we do a DELETE /* at the end of the tests, will be required from 8.0 on, produces a warning since 7.13

0 commit comments

Comments
 (0)