Upgrade Elasticsearch to 9.1.0.

Original Pull Request #3147
Closes #3145
Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
This commit is contained in:
Peter-Josef Meisch 2025-08-06 20:52:04 +02:00 committed by GitHub
parent e49bb63df4
commit 6697755b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 23 additions and 12 deletions

View File

@ -21,7 +21,7 @@
<springdata.commons>4.0.0-SNAPSHOT</springdata.commons>
<!-- version of the ElasticsearchClient -->
<elasticsearch-java>9.0.4</elasticsearch-java>
<elasticsearch-java>9.1.0</elasticsearch-java>
<hoverfly>0.19.0</hoverfly>
<log4j>2.23.1</log4j>

View File

@ -6,7 +6,7 @@
* Upgarde to Spring 7
* Switch to jspecify nullability annotations
* Upgrade to Elasticsearch 9.0.4
* Upgrade to Elasticsearch 9.1.0
* Use the new Elasticsearch Rest5Client as default

View File

@ -6,7 +6,7 @@ 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.1 (in development) | 6.0.x | 9.0.4 | 7.0.x
| 2025.1 (in development) | 6.0.x | 9.1.0 | 7.0.x
| 2025.0 | 5.5.x | 8.18.1 | 6.2.x
| 2024.1 | 5.4.x | 8.15.5 | 6.1.x
| 2024.0 | 5.3.xfootnote:oom[Out of maintenance] | 8.13.4 | 6.1.x

View File

@ -17,6 +17,8 @@ package org.springframework.data.elasticsearch.client.elc;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.*;
import co.elastic.clients.util.NamedValue;
import java.util.Arrays;
import java.util.stream.Collectors;
@ -60,10 +62,11 @@ class HighlightQueryBuilder {
for (HighlightField highlightField : highlight.getFields()) {
String mappedName = mapFieldName(highlightField.getName(), type);
highlightBuilder.fields(mappedName, hf -> {
addParameters(highlightField.getParameters(), hf, type);
return hf;
});
highlightBuilder.fields(
NamedValue.of(mappedName, co.elastic.clients.elasticsearch.core.search.HighlightField.of(hf -> {
addParameters(highlightField.getParameters(), hf, type);
return hf;
})));
}
return highlightBuilder.build();

View File

@ -30,6 +30,7 @@ import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.elasticsearch.ResourceNotFoundException;
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Mapping;
import org.springframework.data.elasticsearch.core.IndexInformation;
@ -315,15 +316,20 @@ public class IndicesTemplate extends ChildTemplate<ElasticsearchTransport, Elast
}
@Override
public TemplateData getTemplate(GetTemplateRequest getTemplateRequest) {
public @Nullable TemplateData getTemplate(GetTemplateRequest getTemplateRequest) {
Assert.notNull(getTemplateRequest, "getTemplateRequest must not be null");
co.elastic.clients.elasticsearch.indices.GetTemplateRequest getTemplateRequestES = requestConverter
.indicesGetTemplateRequest(getTemplateRequest);
GetTemplateResponse getTemplateResponse = execute(client -> client.getTemplate(getTemplateRequestES));
return responseConverter.indicesGetTemplateData(getTemplateResponse, getTemplateRequest.getTemplateName());
try {
GetTemplateResponse getTemplateResponse = execute(client -> client.getTemplate(getTemplateRequestES));
return responseConverter.indicesGetTemplateData(getTemplateResponse, getTemplateRequest.getTemplateName());
} catch (ResourceNotFoundException e) {
// since Elasticsearch 9.1.0 we get an exception (404) instead of an empty result
return null;
}
}
@Override

View File

@ -21,6 +21,7 @@ import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase;
import co.elastic.clients.elasticsearch.indices.*;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.endpoints.BooleanResponse;
import org.springframework.data.elasticsearch.ResourceNotFoundException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -389,7 +390,8 @@ public class ReactiveIndicesTemplate
co.elastic.clients.elasticsearch.indices.GetTemplateRequest getTemplateRequestES = requestConverter
.indicesGetTemplateRequest(getTemplateRequest);
Mono<GetTemplateResponse> getTemplateResponse = Mono
.from(execute(client -> client.getTemplate(getTemplateRequestES)));
.from(execute(client -> client.getTemplate(getTemplateRequestES)))
.onErrorComplete(ResourceNotFoundException.class);
return getTemplateResponse.flatMap(response -> {
if (response != null) {

View File

@ -15,7 +15,7 @@
#
#
sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch
sde.testcontainers.image-version=9.0.4
sde.testcontainers.image-version=9.1.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