Skip to content

Upgrade to Elasticsearch 8.5.0. #2348

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
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<springdata.commons>3.0.0-SNAPSHOT</springdata.commons>

<!-- version of the RestHighLevelClient -->
<elasticsearch-rhlc>7.17.6</elasticsearch-rhlc>
<elasticsearch-rhlc>7.17.7</elasticsearch-rhlc>
<!-- version of the new ElasticsearchClient -->
<elasticsearch-java>8.4.3</elasticsearch-java>
<elasticsearch-java>8.5.0</elasticsearch-java>

<log4j>2.18.0</log4j>
<netty>4.1.65.Final</netty>
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
| 2022.0 (Turing) | 5.0.x | 8.4.3 | 6.0.x | 3.0.x?
| 2022.0 (Turing) | 5.0.x | 8.5.0 | 6.0.x | 3.0.x?
| 2021.2 (Raj) | 4.4.x | 7.17.3 | 5.3.x | 2.7.x
| 2021.1 (Q) | 4.3.x | 7.15.2 | 5.3.x | 2.6.x
| 2021.0 (Pascal) | 4.2.xfootnote:oom[Out of maintenance] | 7.12.0 | 5.3.x | 2.5.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ The old deprecated `RestHighLevelClient` can still be used, but you will need to
----
====

Make sure to specify the version 7.17.6 explicitly, otherwise maven will resolve to 8.4.3, and this does not exist.
Make sure to specify the version 7.17.6 explicitly, otherwise maven will resolve to 8.5.0, and this does not exist.
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public static SearchDocument from(Hit<?> hit, JsonpMapper jsonpMapper) {
document.setPrimaryTerm(hit.primaryTerm() != null && hit.primaryTerm() > 0 ? hit.primaryTerm() : 0);

float score = hit.score() != null ? hit.score().floatValue() : Float.NaN;
return new SearchDocumentAdapter(document, score, hit.sort().toArray(new String[0]), documentFields,
highlightFields, innerHits, nestedMetaData, explanation, matchedQueries, hit.routing());
return new SearchDocumentAdapter(document, score, hit.sort().stream().map(TypeUtils::toString).toArray(),
documentFields, highlightFields, innerHits, nestedMetaData, explanation, matchedQueries, hit.routing());
}

public static SearchDocument from(CompletionSuggestOption<EntityAsMap> completionSuggestOption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.springframework.util.CollectionUtils.*;

import co.elastic.clients.elasticsearch._types.Conflicts;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.InlineScript;
import co.elastic.clients.elasticsearch._types.OpType;
import co.elastic.clients.elasticsearch._types.SortOptions;
Expand Down Expand Up @@ -735,7 +736,7 @@ public co.elastic.clients.elasticsearch.core.ReindexRequest reindex(ReindexReque

ReindexRequest.Slice slice = source.getSlice();
if (slice != null) {
s.slice(sl -> sl.id(slice.getId()).max(slice.getMax()));
s.slice(sl -> sl.id(String.valueOf(slice.getId())).max(slice.getMax()));
}

if (source.getQuery() != null) {
Expand Down Expand Up @@ -1100,7 +1101,8 @@ public MsearchRequest searchMsearchRequest(
}

if (!isEmpty(query.getSearchAfter())) {
bb.searchAfter(query.getSearchAfter().stream().map(Object::toString).collect(Collectors.toList()));
bb.searchAfter(query.getSearchAfter().stream().map(it -> FieldValue.of(it.toString()))
.collect(Collectors.toList()));
}

query.getRescorerQueries().forEach(rescorerQuery -> bb.rescore(getRescore(rescorerQuery)));
Expand Down Expand Up @@ -1241,7 +1243,8 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind
}

if (!isEmpty(query.getSearchAfter())) {
builder.searchAfter(query.getSearchAfter().stream().map(Object::toString).collect(Collectors.toList()));
builder.searchAfter(
query.getSearchAfter().stream().map(it -> FieldValue.of(it.toString())).collect(Collectors.toList()));
}

query.getRescorerQueries().forEach(rescorerQuery -> builder.rescore(getRescore(rescorerQuery)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,37 @@ static FieldType fieldType(String type) {
return null;
}

@Nullable
static String toString(@Nullable FieldValue fieldValue) {

if (fieldValue == null) {
return null;
}

switch (fieldValue._kind()) {
case Double -> {
return String.valueOf(fieldValue.doubleValue());
}
case Long -> {
return String.valueOf(fieldValue.longValue());
}
case Boolean -> {
return String.valueOf(fieldValue.booleanValue());
}
case String -> {
return fieldValue.stringValue();
}
case Null -> {
return null;
}
case Any -> {
return fieldValue.anyValue().toString();
}

default -> throw new IllegalStateException("Unexpected value: " + fieldValue._kind());
}
}

@Nullable
static GeoDistanceType geoDistanceType(GeoDistanceOrder.DistanceType distanceType) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ protected <A extends AggregationContainer<?>> void assertThatAggregationsAreCorr
assertThat(bucketList.size()).isEqualTo(3);
AtomicInteger count = new AtomicInteger();
bucketList.forEach(stringTermsBucket -> {
if ("message".equals(stringTermsBucket.key())) {
if ("message".equals(stringTermsBucket.key().stringValue())) {
count.getAndIncrement();
assertThat(stringTermsBucket.docCount()).isEqualTo(3);
}
if ("some".equals(stringTermsBucket.key())) {
if ("some".equals(stringTermsBucket.key().stringValue())) {
count.getAndIncrement();
assertThat(stringTermsBucket.docCount()).isEqualTo(2);
}
if ("other".equals(stringTermsBucket.key())) {
if ("other".equals(stringTermsBucket.key().stringValue())) {
count.getAndIncrement();
assertThat(stringTermsBucket.docCount()).isEqualTo(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void shouldReturnEmptyListOnDerivedMethodWithEmptyInputList() {
assertThat(products).isEmpty();
}

@Disabled("issue #2300, Elasticsearch bug https://github.com/elastic/elasticsearch/issues/89760")
@Test // #1909
@DisplayName("should find by property exists")
void shouldFindByPropertyExists() {
Expand All @@ -276,7 +275,6 @@ void shouldFindByPropertyExists() {
assertThat(searchHits.getTotalHits()).isEqualTo(6);
}

@Disabled("issue #2300, Elasticsearch bug https://github.com/elastic/elasticsearch/issues/89760")
@Test // #1909
@DisplayName("should find by property is not null")
void shouldFindByPropertyIsNotNull() {
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.4.3
sde.testcontainers.image-version=8.5.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