Skip to content

Upgrade to Elasticsearch 8.16.1. #3019

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 2 commits into from
Dec 1, 2024
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.5.0-SNAPSHOT</springdata.commons>

<!-- version of the ElasticsearchClient -->
<elasticsearch-java>8.15.3</elasticsearch-java>
<elasticsearch-java>8.16.1</elasticsearch-java>

<hoverfly>0.19.0</hoverfly>
<log4j>2.23.1</log4j>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[[new-features]]
= What's new

[[new-features.5-5-0]]
== New in Spring Data Elasticsearch 5.5
* Upgrade to Elasticsearch 8.16.1.

[[new-features.5-4-0]]
== New in Spring Data Elasticsearch 5.4

* Upgrade to Elasticsearch 8.15.3.
* Allow to customize the mapped type name for `@InnerField` and `@Field` annotations.
* Support for Elasticsearch SQL.
* Add support for retrieving request executionDuration.
* Add support for retrieving request executionDuration.

[[new-features.5-3-0]]
== New in Spring Data Elasticsearch 5.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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.0 (in development) | 5.5.x | 8.15.3 | 6.2.x
| 2024.1 | 5.4.x | 8.15.3 | 6.1.x
| 2025.0 (in development) | 5.5.x | 8.16.1 | 6.2.x
| 2024.1 | 5.4.x | 8.15.5 | 6.1.x
| 2024.0 | 5.3.x | 8.13.4 | 6.1.x
| 2023.1 (Vaughan) | 5.2.xfootnote:oom[Out of maintenance] | 8.11.1 | 6.1.x
| 2023.0 (Ullmann) | 5.1.xfootnote:oom[] | 8.7.1 | 6.0.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.transport.ElasticsearchTransport;

import java.io.IOException;

import org.elasticsearch.client.RestClient;
import org.springframework.util.Assert;

Expand All @@ -36,7 +38,10 @@ public AutoCloseableElasticsearchClient(ElasticsearchTransport transport) {
}

@Override
public void close() throws Exception {
transport.close();
public void close() throws IOException {
// since Elasticsearch 8.16 the ElasticsearchClient implements (through ApiClient) the Closeable interface and
// handles closing of the underlying transport. We now just call the base class, but keep this as we
// have been implementing AutoCloseable since 4.4 and won't change that to a mere Closeable
super.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public static ElasticsearchTransport getElasticsearchTransport(RestClient restCl
Assert.notNull(jsonpMapper, "jsonpMapper must not be null");

TransportOptions.Builder transportOptionsBuilder = transportOptions != null ? transportOptions.toBuilder()
: new RestClientOptions(RequestOptions.DEFAULT).toBuilder();
: new RestClientOptions(RequestOptions.DEFAULT, false).toBuilder();

RestClientOptions.Builder restClientOptionsBuilder = getRestClientOptionsBuilder(transportOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ public JsonpMapper jsonpMapper() {
* @return the options that should be added to every request. Must not be {@literal null}
*/
public TransportOptions transportOptions() {
return new RestClientOptions(RequestOptions.DEFAULT);
return new RestClientOptions(RequestOptions.DEFAULT, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import co.elastic.clients.util.ObjectBuilder;
import reactor.core.publisher.Mono;

import java.io.IOException;
import java.util.function.Function;

import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -56,8 +57,11 @@ public ReactiveElasticsearchClient withTransportOptions(@Nullable TransportOptio
}

@Override
public void close() throws Exception {
transport.close();
public void close() throws IOException {
// since Elasticsearch 8.16 the ElasticsearchClient implements (through ApiClient) the Closeable interface and
// handles closing of the underlying transport. We now just call the base class, but keep this as we
// have been implementing AutoCloseable since 4.4 and won't change that to a mere Closeable
super.close();
}

// region child clients
Expand Down Expand Up @@ -127,7 +131,8 @@ public <T> Mono<GetResponse<T>> get(GetRequest request, Class<T> tClass) {
// java.lang.Class<TDocument>)
// noinspection unchecked
JsonEndpoint<GetRequest, GetResponse<T>, ErrorResponse> endpoint = (JsonEndpoint<GetRequest, GetResponse<T>, ErrorResponse>) GetRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:_global.get.Response.TDocument",
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:_global.get.Response.TDocument",
getDeserializer(tClass));

return Mono.fromFuture(transport.performRequestAsync(request, endpoint, transportOptions));
Expand Down Expand Up @@ -172,7 +177,8 @@ public <T> Mono<MgetResponse<T>> mget(MgetRequest request, Class<T> clazz) {

// noinspection unchecked
JsonEndpoint<MgetRequest, MgetResponse<T>, ErrorResponse> endpoint = (JsonEndpoint<MgetRequest, MgetResponse<T>, ErrorResponse>) MgetRequest._ENDPOINT;
endpoint = new EndpointWithResponseMapperAttr<>(endpoint, "co.elastic.clients:Deserializer:_global.mget.Response.TDocument",
endpoint = new EndpointWithResponseMapperAttr<>(endpoint,
"co.elastic.clients:Deserializer:_global.mget.Response.TDocument",
this.getDeserializer(clazz));

return Mono.fromFuture(transport.performRequestAsync(request, endpoint, transportOptions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ public JsonpMapper jsonpMapper() {
* @return the options that should be added to every request. Must not be {@literal null}
*/
public TransportOptions transportOptions() {
return new RestClientOptions(RequestOptions.DEFAULT).toBuilder().build();
return new RestClientOptions(RequestOptions.DEFAULT, false).toBuilder().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import co.elastic.clients.elasticsearch.indices.ExistsIndexTemplateRequest;
import co.elastic.clients.elasticsearch.indices.ExistsRequest;
import co.elastic.clients.elasticsearch.indices.update_aliases.Action;
import co.elastic.clients.elasticsearch.sql.query.SqlFormat;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
Expand Down Expand Up @@ -533,17 +534,22 @@ public co.elastic.clients.elasticsearch.indices.GetTemplateRequest indicesGetTem
public co.elastic.clients.elasticsearch.sql.QueryRequest sqlQueryRequest(SqlQuery query) {
Assert.notNull(query, "Query must not be null.");

return co.elastic.clients.elasticsearch.sql.QueryRequest.of(sqb -> {
sqb.query(query.getQuery()).catalog(query.getCatalog()).columnar(query.getColumnar()).cursor(query.getCursor())
.fetchSize(query.getFetchSize()).fieldMultiValueLeniency(query.getFieldMultiValueLeniency())
.indexUsingFrozen(query.getIndexIncludeFrozen()).keepAlive(time(query.getKeepAlive()))
.keepOnCompletion(query.getKeepOnCompletion()).pageTimeout(time(query.getPageTimeout()))
.requestTimeout(time(query.getRequestTimeout()))
.waitForCompletionTimeout(time(query.getWaitForCompletionTimeout())).filter(getQuery(query.getFilter(), null))
.timeZone(Objects.toString(query.getTimeZone(), null)).format("json");

return sqb;
});
return co.elastic.clients.elasticsearch.sql.QueryRequest.of(sqb -> sqb
.query(query.getQuery())
.catalog(query.getCatalog())
.columnar(query.getColumnar())
.cursor(query.getCursor())
.fetchSize(query.getFetchSize())
.fieldMultiValueLeniency(query.getFieldMultiValueLeniency())
.indexUsingFrozen(query.getIndexIncludeFrozen())
.keepAlive(time(query.getKeepAlive()))
.keepOnCompletion(query.getKeepOnCompletion())
.pageTimeout(time(query.getPageTimeout()))
.requestTimeout(time(query.getRequestTimeout()))
.waitForCompletionTimeout(time(query.getWaitForCompletionTimeout()))
.filter(getQuery(query.getFilter(), null))
.timeZone(Objects.toString(query.getTimeZone(), null))
.format(SqlFormat.Json));
}

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public String getBoundaryScannerLocale() {
return boundaryScannerLocale;
}

/**
* @deprecated the underlying functionality is deprecated since Elasticsearch 8.8.
*/
@Deprecated(since = "5.5")
public boolean getForceSource() {
return forceSource;
}
Expand Down Expand Up @@ -173,6 +177,10 @@ public SELF withBoundaryScannerLocale(String boundaryScannerLocale) {
return (SELF) this;
}

/**
* @deprecated the underlying functionality is deprecated since Elasticsearch 8.8.
*/
@Deprecated(since = "5.5")
public SELF withForceSource(boolean forceSource) {
this.forceSource = forceSource;
return (SELF) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ inline fun <reified T : Any> SearchOperations.searchOne(query: Query): SearchHit
inline fun <reified T : Any> SearchOperations.searchOne(query: Query, index: IndexCoordinates): SearchHit<T>? =
searchOne(query, T::class.java, index)

inline fun <reified T : Any> SearchOperations.multiSearch(queries: List<out Query>): List<SearchHits<T>> =
inline fun <reified T : Any> SearchOperations.multiSearch(queries: List<Query>): List<SearchHits<T>> =
multiSearch(queries, T::class.java)

inline fun <reified T : Any> SearchOperations.multiSearch(
queries: List<out Query>,
queries: List<Query>,
index: IndexCoordinates
): List<SearchHits<T>> =
multiSearch(queries, T::class.java, index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class DevTests {
private static final SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
private static final MappingElasticsearchConverter converter = new MappingElasticsearchConverter(mappingContext);

private final TransportOptions transportOptions = new RestClientOptions(RequestOptions.DEFAULT).toBuilder()
private final TransportOptions transportOptions = new RestClientOptions(RequestOptions.DEFAULT, false).toBuilder()
.addHeader("X-SpringDataElasticsearch-AlwaysThere", "true").setParameter("pretty", "true").build();

private final JsonpMapper jsonpMapper = new JacksonJsonpMapper();
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.15.3
sde.testcontainers.image-version=8.16.1
#
#
# 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