Upgrade to Elasticsearch 8.5.0.

Original Pull Request #2348
Closes #2345
Closes #2300
This commit is contained in:
Peter-Josef Meisch 2022-11-02 18:42:41 +01:00
parent 5da1994b40
commit 744b3ed6b4
No known key found for this signature in database
GPG Key ID: DE108246970C7708
9 changed files with 47 additions and 15 deletions

View File

@ -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>

View File

@ -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

View File

@ -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.

View File

@ -138,8 +138,8 @@ final class DocumentAdapters {
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) {

View File

@ -19,6 +19,7 @@ import static org.springframework.data.elasticsearch.client.elc.TypeUtils.*;
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;
@ -735,7 +736,7 @@ class RequestConverter {
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) {
@ -1100,7 +1101,8 @@ class RequestConverter {
}
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)));
@ -1241,7 +1243,8 @@ class RequestConverter {
}
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)));

View File

@ -95,6 +95,37 @@ final class TypeUtils {
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) {

View File

@ -104,15 +104,15 @@ public class ReactiveElasticsearchELCIntegrationTests extends ReactiveElasticsea
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);
}

View File

@ -266,7 +266,6 @@ abstract class QueryKeywordsIntegrationTests {
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() {
@ -276,7 +275,6 @@ abstract class QueryKeywordsIntegrationTests {
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() {

View File

@ -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