Skip to content

Upgrade to Elasticsearch 8.9.0. #2656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<springdata.commons>3.2.0-SNAPSHOT</springdata.commons>

<!-- version of the ElasticsearchClient -->
<elasticsearch-java>8.8.2</elasticsearch-java>
<elasticsearch-java>8.9.0</elasticsearch-java>

<blockhound-junit>1.0.8.RELEASE</blockhound-junit>
<hoverfly>0.14.4</hoverfly>
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/preface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ built and tested.
[cols="^,^,^,^,^",options="header"]
|===
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot
| 2023.1 (Vaughan) | 5.2.x | 8.8.2 | 6.0.x | 3.1.x
| 2023.1 (Vaughan) | 5.2.x | 8.9.0 | 6.0.x | 3.1.x
| 2023.0 (Ullmann) | 5.1.x | 8.7.1 | 6.0.x | 3.1.x
| 2022.0 (Turing) | 5.0.x | 8.5.3 | 6.0.x | 3.0.x
| 2021.2 (Raj) | 4.4.xfootnote:oom[Out of maintenance] | 7.17.3 | 5.3.x | 2.7.x
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/reference/elasticsearch-new.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[[new-features.5-2-0]]
== New in Spring Data Elasticsearch 5.2

* Upgrade to Elasticsearch 8.8.2
* Upgrade to Elasticsearch 8.9.0
* The `JsonpMapper` for Elasticsearch is now configurable and provided as bean.
* Improved AOT runtime hints for Elasticsearch client library classes.
* Add Kotlin extensions and repository coroutine support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

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

RestClientOptions.Builder restClientOptionsBuilder = getRestClientOptionsBuilder(transportOptions);

ContentType jsonContentType = Version.VERSION == null ? ContentType.APPLICATION_JSON
: ContentType.create("application/vnd.elasticsearch+json",
new BasicNameValuePair("compatible-with", String.valueOf(Version.VERSION.major())));

Consumer<String> setHeaderIfNotPresent = header -> {
if (transportOptionsBuilder.build().headers().stream() //
if (restClientOptionsBuilder.build().headers().stream() //
.noneMatch((h) -> h.getKey().equalsIgnoreCase(header))) {
// need to add the compatibility header, this is only done automatically when not passing in custom options.
// code copied from RestClientTransport as it is not available outside the package
transportOptionsBuilder.addHeader(header, jsonContentType.toString());
restClientOptionsBuilder.addHeader(header, jsonContentType.toString());
}
};

§
setHeaderIfNotPresent.accept("Content-Type");
setHeaderIfNotPresent.accept("Accept");

TransportOptions transportOptionsWithHeader = transportOptionsBuilder
.addHeader(X_SPRING_DATA_ELASTICSEARCH_CLIENT, clientType).build();
restClientOptionsBuilder.addHeader(X_SPRING_DATA_ELASTICSEARCH_CLIENT, clientType);

return new RestClientTransport(restClient, jsonpMapper, restClientOptionsBuilder.build());
}

private static RestClientOptions.Builder getRestClientOptionsBuilder(@Nullable TransportOptions transportOptions) {

return new RestClientTransport(restClient, jsonpMapper, transportOptionsWithHeader);
if (transportOptions instanceof RestClientOptions restClientOptions) {
return restClientOptions.toBuilder();
}

var builder = new RestClientOptions.Builder(RequestOptions.DEFAULT.toBuilder());

if (transportOptions != null) {
transportOptions.headers().forEach(header -> builder.addHeader(header.getKey(), header.getValue()));
transportOptions.queryParameters().forEach(builder::setParameter);
builder.onWarnings(transportOptions.onWarnings());
}

return builder;
}

private static List<String> formattedHosts(List<InetSocketAddress> hosts, boolean useSsl) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/testcontainers-elasticsearch.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
#
sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch
sde.testcontainers.image-version=8.8.2
sde.testcontainers.image-version=8.9.0
#
#
# 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
Expand Down