From 148a9303f51ffe5ba4f341a0e7bab22d16525559 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Fri, 10 Dec 2021 08:07:17 +0100 Subject: [PATCH] Adapt to Elasticsearch 7.16.0 --- pom.xml | 2 +- src/main/asciidoc/preface.adoc | 11 +++++----- .../asciidoc/reference/elasticsearch-new.adoc | 5 +++++ .../DefaultReactiveElasticsearchClient.java | 8 +++---- .../client/util/NamedXContents.java | 6 +++--- .../client/util/RequestConverters.java | 21 ++++++++++++------- .../elasticsearch7/RequestFactoryTests.java | 4 ++-- .../ReactiveElasticsearchClientUnitTests.java | 2 +- .../core/DocumentAdaptersUnitTests.java | 4 ++-- ...ompletionWithContextsIntegrationTests.java | 11 ++++++---- .../testcontainers-elasticsearch.properties | 2 +- 11 files changed, 45 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 5bec33960..c5c10ae35 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ https://github.com/spring-projects/spring-data-elasticsearch - 7.15.2 + 7.16.0 2.14.1 4.1.65.Final 2.7.0-SNAPSHOT diff --git a/src/main/asciidoc/preface.adoc b/src/main/asciidoc/preface.adoc index 22f994dd7..4a26c8453 100644 --- a/src/main/asciidoc/preface.adoc +++ b/src/main/asciidoc/preface.adoc @@ -34,12 +34,13 @@ The following table shows the Elasticsearch versions that are used by Spring Dat [cols="^,^,^,^,^",options="header"] |=== | Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot -| 2021.1 (Q)footnote:cdv[Currently in development] | 4.3.xfootnote:cdv[] | 7.15.2 | 5.3.xfootnote:cdv[] | 2.5 .xfootnote:cdv[] +| 2022.0 (Raj) | 4.4.x | 7.16.0 | 5.3.x | +| 2021.1 (Q) | 4.3.x | 7.15.2 | 5.3.x | 2.6.x | 2021.0 (Pascal) | 4.2.x | 7.12.0 | 5.3.x | 2.5.x -| 2020.0 (Ockham) | 4.1.x | 7.9.3 | 5.3.2 | 2.4.x -| Neumann | 4.0.x | 7.6.2 | 5.2.12 |2.3.x -| Moore | 3.2.x |6.8.12 | 5.2.12| 2.2.x -| Lovelacefootnote:oom[Out of maintenance] | 3.1.xfootnote:oom[] | 6.2.2 | 5.1.19 |2.1.x +| 2020.0 (Ockham)footnote:oom[Out of maintenance] | 4.1.xfootnote:oom[] | 7.9.3 | 5.3.2 | 2.4.x +| Neumannfootnote:oom[] | 4.0.xfootnote:oom[] | 7.6.2 | 5.2.12 |2.3.x +| Moorefootnote:oom[] | 3.2.xfootnote:oom[] |6.8.12 | 5.2.12| 2.2.x +| Lovelacefootnote:oom[] | 3.1.xfootnote:oom[] | 6.2.2 | 5.1.19 |2.1.x | Kayfootnote:oom[] | 3.0.xfootnote:oom[] | 5.5.0 | 5.0.13 | 2.0.x | Ingallsfootnote:oom[] | 2.1.xfootnote:oom[] | 2.4.0 | 4.3.25 | 1.5.x |=== diff --git a/src/main/asciidoc/reference/elasticsearch-new.adoc b/src/main/asciidoc/reference/elasticsearch-new.adoc index 1141a1420..4eb35beb8 100644 --- a/src/main/asciidoc/reference/elasticsearch-new.adoc +++ b/src/main/asciidoc/reference/elasticsearch-new.adoc @@ -1,6 +1,11 @@ [[new-features]] = What's new +[[new-features.4-4-0]] +== New in Spring Data Elasticsearch 4.4 + +* Upgrade to Elasticsearch 7.16.0. + [[new-features.4-3-0]] == New in Spring Data Elasticsearch 4.3 diff --git a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/DefaultReactiveElasticsearchClient.java b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/DefaultReactiveElasticsearchClient.java index e7a2faeaa..cc26cfc70 100644 --- a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/DefaultReactiveElasticsearchClient.java +++ b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/DefaultReactiveElasticsearchClient.java @@ -83,10 +83,6 @@ import org.elasticsearch.client.GetAliasesResponse; import org.elasticsearch.client.Request; import org.elasticsearch.client.indices.*; -import org.elasticsearch.common.xcontent.DeprecationHandler; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.index.reindex.BulkByScrollResponse; @@ -100,6 +96,10 @@ import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.suggest.Suggest; +import org.elasticsearch.xcontent.DeprecationHandler; +import org.elasticsearch.xcontent.NamedXContentRegistry; +import org.elasticsearch.xcontent.XContentParser; +import org.elasticsearch.xcontent.XContentType; import org.reactivestreams.Publisher; import org.springframework.data.elasticsearch.RestStatusException; import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; diff --git a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/NamedXContents.java b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/NamedXContents.java index 077b2f3ec..8a6a76d19 100644 --- a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/NamedXContents.java +++ b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/NamedXContents.java @@ -26,9 +26,6 @@ import org.elasticsearch.client.analytics.ParsedTopMetrics; import org.elasticsearch.client.analytics.StringStatsAggregationBuilder; import org.elasticsearch.client.analytics.TopMetricsAggregationBuilder; -import org.elasticsearch.common.xcontent.ContextParser; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.common.xcontent.ParseField; import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.adjacency.ParsedAdjacencyMatrix; @@ -78,6 +75,9 @@ import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder; import org.elasticsearch.search.suggest.term.TermSuggestion; import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; +import org.elasticsearch.xcontent.ContextParser; +import org.elasticsearch.xcontent.NamedXContentRegistry; +import org.elasticsearch.xcontent.ParseField; import org.springframework.data.elasticsearch.backend.elasticsearch7.client.reactive.ReactiveElasticsearchClient; /** diff --git a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/RequestConverters.java b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/RequestConverters.java index 6fb85b979..2236873bf 100644 --- a/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/RequestConverters.java +++ b/src/main/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/util/RequestConverters.java @@ -80,14 +80,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.lucene.uid.Versions; -import org.elasticsearch.common.xcontent.DeprecationHandler; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContent; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.VersionType; @@ -101,6 +94,13 @@ import org.elasticsearch.script.mustache.SearchTemplateRequest; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.tasks.TaskId; +import org.elasticsearch.xcontent.DeprecationHandler; +import org.elasticsearch.xcontent.NamedXContentRegistry; +import org.elasticsearch.xcontent.ToXContent; +import org.elasticsearch.xcontent.XContent; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentParser; +import org.elasticsearch.xcontent.XContentType; import org.springframework.data.elasticsearch.backend.elasticsearch7.client.reactive.ReactiveElasticsearchClient; import org.springframework.http.HttpMethod; import org.springframework.lang.Nullable; @@ -1232,7 +1232,12 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCou return this; } - Params withIndicesOptions(IndicesOptions indicesOptions) { + Params withIndicesOptions(@Nullable IndicesOptions indicesOptions) { + + if (indicesOptions == null) { + return this; + } + withIgnoreUnavailable(indicesOptions.ignoreUnavailable()); putParam("allow_no_indices", Boolean.toString(indicesOptions.allowNoIndices())); String expandWildcards; diff --git a/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/RequestFactoryTests.java b/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/RequestFactoryTests.java index fc686343e..8697a7ede 100644 --- a/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/RequestFactoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/RequestFactoryTests.java @@ -31,13 +31,13 @@ import org.elasticsearch.client.indices.PutIndexTemplateRequest; import org.elasticsearch.common.lucene.search.function.CombineFunction; import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder; import org.elasticsearch.index.query.functionscore.GaussDecayFunctionBuilder; +import org.elasticsearch.xcontent.ToXContent; +import org.elasticsearch.xcontent.XContentType; import org.json.JSONException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/ReactiveElasticsearchClientUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/ReactiveElasticsearchClientUnitTests.java index 3d88cd978..cec92301e 100644 --- a/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/ReactiveElasticsearchClientUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/backend/elasticsearch7/client/reactive/ReactiveElasticsearchClientUnitTests.java @@ -35,12 +35,12 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; import org.elasticsearch.search.aggregations.metrics.ParsedMax; +import org.elasticsearch.xcontent.XContentType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/src/test/java/org/springframework/data/elasticsearch/core/DocumentAdaptersUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/DocumentAdaptersUnitTests.java index f8b781042..bfcb2f7cd 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/DocumentAdaptersUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/DocumentAdaptersUnitTests.java @@ -142,7 +142,7 @@ public void shouldAdaptSearchResponse() { Map fields = Collections.singletonMap("field", new DocumentField("field", Collections.singletonList("value"))); - SearchShardTarget shard = new SearchShardTarget("node", new ShardId("index", "uuid", 42), null, null); + SearchShardTarget shard = new SearchShardTarget("node", new ShardId("index", "uuid", 42), null); SearchHit searchHit = new SearchHit(123, "my-id", new Text("type"), null, fields); searchHit.shard(shard); searchHit.setSeqNo(1); @@ -217,7 +217,7 @@ public void shouldAdaptSearchResponseSource() { BytesArray source = new BytesArray("{\"field\":\"value\"}"); - SearchShardTarget shard = new SearchShardTarget("node", new ShardId("index", "uuid", 42), null, null); + SearchShardTarget shard = new SearchShardTarget("node", new ShardId("index", "uuid", 42), null); SearchHit searchHit = new SearchHit(123, "my-id", new Text("type"), null, null); searchHit.shard(shard); searchHit.sourceRef(source).score(42); diff --git a/src/test/java/org/springframework/data/elasticsearch/core/suggest/CompletionWithContextsIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/suggest/CompletionWithContextsIntegrationTests.java index e918343de..c4bd06454 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/suggest/CompletionWithContextsIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/suggest/CompletionWithContextsIntegrationTests.java @@ -25,13 +25,13 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.unit.Fuzziness; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.search.suggest.SuggestBuilder; import org.elasticsearch.search.suggest.SuggestBuilders; import org.elasticsearch.search.suggest.SuggestionBuilder; import org.elasticsearch.search.suggest.completion.CompletionSuggestion; import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder; import org.elasticsearch.search.suggest.completion.context.CategoryQueryContext; +import org.elasticsearch.xcontent.ToXContent; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -207,7 +207,8 @@ public void shouldFindSuggestionsForGivenCriteriaQueryUsingContextCompletionEnti */ static class NonDocumentEntity { - @Nullable @Id private String someId; + @Nullable + @Id private String someId; @Nullable private String someField1; @Nullable private String someField2; @@ -238,10 +239,12 @@ public void setSomeField2(String someField2) { static class ContextCompletionEntity { public static final String LANGUAGE_CATEGORY = "language"; - @Nullable @Id private String id; + @Nullable + @Id private String id; @Nullable private String name; - @Nullable @CompletionField(maxInputLength = 100, contexts = { @CompletionContext(name = LANGUAGE_CATEGORY, + @Nullable + @CompletionField(maxInputLength = 100, contexts = { @CompletionContext(name = LANGUAGE_CATEGORY, type = CompletionContext.ContextMappingType.CATEGORY) }) private Completion suggest; private ContextCompletionEntity() {} diff --git a/src/test/resources/testcontainers-elasticsearch.properties b/src/test/resources/testcontainers-elasticsearch.properties index a1a418b17..b848d5ab8 100644 --- a/src/test/resources/testcontainers-elasticsearch.properties +++ b/src/test/resources/testcontainers-elasticsearch.properties @@ -17,7 +17,7 @@ # properties defining the image, these are not passed to the container on startup # sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch -sde.testcontainers.image-version=7.15.2 +sde.testcontainers.image-version=7.16.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