From 44a79093cee8995d646ea18319fddbda79dceae9 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Sat, 6 Aug 2022 23:16:38 +0200 Subject: [PATCH] Remove deprecated code. Original Pull request #2256 Closes #2255 --- ...elasticsearch-migration-guide-4.4-5.0.adoc | 9 ++++ .../elasticsearch/annotations/DateFormat.java | 17 ++------ .../elasticsearch/annotations/Document.java | 43 ------------------- .../annotations/DynamicMapping.java | 40 ----------------- .../annotations/DynamicMappingValue.java | 39 ----------------- .../data/elasticsearch/annotations/Query.java | 7 --- .../client/ClientConfiguration.java | 31 ------------- .../client/ClientConfigurationBuilder.java | 22 ---------- .../client/DefaultClientConfiguration.java | 6 --- .../erhlc/ReactiveElasticsearchClient.java | 2 + .../erhlc/RequestBodyEncodingException.java | 4 +- .../core/AbstractElasticsearchTemplate.java | 6 --- .../core/DocumentOperations.java | 14 ------ .../data/elasticsearch/core/SearchHit.java | 10 ----- .../convert/ElasticsearchDateConverter.java | 1 - .../core/index/MappingBuilder.java | 32 +++++++------- .../core/index/MappingParameters.java | 3 -- .../SimpleElasticsearchPersistentEntity.java | 14 +++--- ...SimpleElasticsearchPersistentProperty.java | 3 -- .../SimpleElasticsearchRepository.java | 8 ++-- .../client/ClientConfigurationUnitTests.java | 10 ++--- .../ElasticsearchDateConverterUnitTests.java | 2 - ...appingElasticsearchConverterUnitTests.java | 3 +- .../index/MappingBuilderIntegrationTests.java | 12 ++---- .../core/index/MappingBuilderUnitTests.java | 12 ++---- ...sticsearchPersistentPropertyUnitTests.java | 2 +- 26 files changed, 59 insertions(+), 293 deletions(-) delete mode 100644 src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMapping.java delete mode 100644 src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java diff --git a/src/main/asciidoc/reference/elasticsearch-migration-guide-4.4-5.0.adoc b/src/main/asciidoc/reference/elasticsearch-migration-guide-4.4-5.0.adoc index 1296c4abf..9508e127d 100644 --- a/src/main/asciidoc/reference/elasticsearch-migration-guide-4.4-5.0.adoc +++ b/src/main/asciidoc/reference/elasticsearch-migration-guide-4.4-5.0.adoc @@ -13,6 +13,15 @@ See <>, all cla deprecated, as the default client implementations to use are the ones based on the new Java Client from Elasticsearch, see <> +=== Removal of deprecated code + +`DateFormat.none` and `DateFormat.custom` had been deprecated since version 4.2 and have been removed. + +The properties of `@Document` that were deprecated since 4.2 have been removed. Use the `@Settings` annotation for +these. + +`@DynamicMapping` and `@DynamicMappingValue` have been removed. Use `@Document.dynamic` or `@Field.dynamic` instead. + [[elasticsearch-migration-guide-4.4-5.0.breaking-changes]] == Breaking Changes diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/DateFormat.java b/src/main/java/org/springframework/data/elasticsearch/annotations/DateFormat.java index 8cf1fb716..eca6b189f 100644 --- a/src/main/java/org/springframework/data/elasticsearch/annotations/DateFormat.java +++ b/src/main/java/org/springframework/data/elasticsearch/annotations/DateFormat.java @@ -18,7 +18,9 @@ package org.springframework.data.elasticsearch.annotations; /** * Values based on reference doc - https://www.elastic.co/guide/reference/mapping/date-format/. The patterns are taken * from this documentation and slightly adapted so that a Java {@link java.time.format.DateTimeFormatter} produces the - * same values as the Elasticsearch formatter. + * same values as the Elasticsearch formatter. Use format = {} to disable built-in date * formats in + * the @Field annotation. If you want to use only a custom date format pattern, you must set the format * + * property to empty {}. * * @author Jakub Vavrik * @author Tim te Beek @@ -26,19 +28,6 @@ package org.springframework.data.elasticsearch.annotations; * @author Sascha Woo */ public enum DateFormat { - /** - * @deprecated since 4.2, will be removed in a future version. Use format = {} to disable built-in date - * formats in the @Field annotation. - */ - @Deprecated - none(""), // - /** - * @deprecated since 4.2, will be removed in a future version.It is no longer required for using a custom date format - * pattern. If you want to use only a custom date format pattern, you must set the format - * property to empty {}. - */ - @Deprecated - custom(""), // basic_date("uuuuMMdd"), // basic_date_time("uuuuMMdd'T'HHmmss.SSSXXX"), // basic_date_time_no_millis("uuuuMMdd'T'HHmmssXXX"), // diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/Document.java b/src/main/java/org/springframework/data/elasticsearch/annotations/Document.java index 64d79fb94..692836527 100644 --- a/src/main/java/org/springframework/data/elasticsearch/annotations/Document.java +++ b/src/main/java/org/springframework/data/elasticsearch/annotations/Document.java @@ -53,49 +53,6 @@ public @interface Document { */ String indexName(); - /** - * Use server-side settings when creating the index. - * - * @deprecated since 4.2, use the {@link Setting} annotation to configure settings - */ - @Deprecated - boolean useServerConfiguration() default false; - - /** - * Number of shards for the index {@link #indexName()}. Used for index creation.
- * With version 4.0, the default value is changed from 5 to 1 to reflect the change in the default settings of - * Elasticsearch which changed to 1 as well in Elasticsearch 7.0. - * ComposableAnnotationsUnitTest.documentAnnotationShouldBeComposable:60 - * - * @deprecated since 4.2, use the {@link Setting} annotation to configure settings - */ - @Deprecated - short shards() default 1; - - /** - * Number of replicas for the index {@link #indexName()}. Used for index creation. - * - * @deprecated since 4.2, use the {@link Setting} annotation to configure settings - */ - @Deprecated - short replicas() default 1; - - /** - * Refresh interval for the index {@link #indexName()}. Used for index creation. - * - * @deprecated since 4.2, use the {@link Setting} annotation to configure settings - */ - @Deprecated - String refreshInterval() default "1s"; - - /** - * Index storage type for the index {@link #indexName()}. Used for index creation. - * - * @deprecated since 4.2, use the {@link Setting} annotation to configure settings - */ - @Deprecated - String indexStoreType() default "fs"; - /** * Configuration whether to create an index on repository bootstrapping. */ diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMapping.java b/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMapping.java deleted file mode 100644 index 4a63b77fa..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMapping.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.elasticsearch.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation to set the dynamic mapping mode - * {@see elasticsearch doc} - * - * @author Peter-Josef Meisch - * @author Sascha Woo - * @since 4.0 - * @deprecated since 4.3, use {@link Document#dynamic()} or {@link Field#dynamic()} instead. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.FIELD }) -@Documented -@Deprecated -public @interface DynamicMapping { - - DynamicMappingValue value() default DynamicMappingValue.True; -} diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java b/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java deleted file mode 100644 index 39b4e9fde..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.elasticsearch.annotations; - -/** - * values for the {@link DynamicMapping annotation} - * - * @author Peter-Josef Meisch - * @author Sascha Woo - * @since 4.0 - * @deprecated since 4.3, use {@link Document#dynamic()} or {@link Field#dynamic()} instead. - */ -@Deprecated -public enum DynamicMappingValue { - True("true"), False("false"), Strict("strict"); - - private final String mappedName; - - DynamicMappingValue(String mappedName) { - this.mappedName = mappedName; - } - - public String getMappedName() { - return mappedName; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/Query.java b/src/main/java/org/springframework/data/elasticsearch/annotations/Query.java index ef34cc849..3e748b51f 100644 --- a/src/main/java/org/springframework/data/elasticsearch/annotations/Query.java +++ b/src/main/java/org/springframework/data/elasticsearch/annotations/Query.java @@ -52,13 +52,6 @@ public @interface Query { @AliasFor("value") String query() default ""; - /** - * Named Query Named looked up by repository. - * - * @deprecated since 4.2, not implemented and used anywhere - */ - String name() default ""; - /** * Returns whether the query defined should be executed as count projection. * diff --git a/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java b/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java index 56086f07d..fcbce7edd 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java @@ -171,14 +171,6 @@ public interface ClientConfiguration { */ Function getWebClientConfigurer(); - /** - * @return the Rest Client configuration callback. - * @since 4.2 - * @deprecated since 4.3 use {@link #getClientConfigurers()} - */ - @Deprecated - HttpClientConfigCallback getHttpClientConfigurer(); - /** * @return the client configuration callbacks * @since 4.3 @@ -347,29 +339,6 @@ public interface ClientConfiguration { */ TerminalClientConfigurationBuilder withProxy(String proxy); - /** - * set customization hook in case of a reactive configuration - * - * @param webClientConfigurer function to configure the WebClient - * @return the {@link TerminalClientConfigurationBuilder}. - * @deprecated since 4.3, use {@link #withClientConfigurer(ClientConfigurationCallback)} with - * {@link ReactiveRestClients.WebClientConfigurationCallback} - */ - @Deprecated - TerminalClientConfigurationBuilder withWebClientConfigurer(Function webClientConfigurer); - - /** - * Register a {HttpClientConfigCallback} to configure the non-reactive REST client. - * - * @param httpClientConfigurer configuration callback, must not be null. - * @return the {@link TerminalClientConfigurationBuilder}. - * @since 4.2 - * @deprecated since 4.3, use {@link #withClientConfigurer(ClientConfigurationCallback)} with - * {@link RestClients.RestClientConfigurationCallback} - */ - @Deprecated - TerminalClientConfigurationBuilder withHttpClientConfigurer(HttpClientConfigCallback httpClientConfigurer); - /** * Register a {@link ClientConfigurationCallback} to configure the client. * diff --git a/src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java b/src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java index bccdbb247..36d13b4f2 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java @@ -202,28 +202,6 @@ class ClientConfigurationBuilder return this; } - @Override - public TerminalClientConfigurationBuilder withWebClientConfigurer( - Function webClientConfigurer) { - - Assert.notNull(webClientConfigurer, "webClientConfigurer must not be null"); - - this.webClientConfigurer = webClientConfigurer; - this.clientConfigurers.add(ReactiveRestClients.WebClientConfigurationCallback.from(webClientConfigurer)); - return this; - } - - @Override - public TerminalClientConfigurationBuilder withHttpClientConfigurer(HttpClientConfigCallback httpClientConfigurer) { - - Assert.notNull(httpClientConfigurer, "httpClientConfigurer must not be null"); - - this.httpClientConfigurer = httpClientConfigurer; - this.clientConfigurers - .add(RestClients.RestClientConfigurationCallback.from(httpClientConfigurer::customizeHttpClient)); - return this; - } - @Override public TerminalClientConfigurationBuilder withClientConfigurer( ClientConfiguration.ClientConfigurationCallback clientConfigurer) { diff --git a/src/main/java/org/springframework/data/elasticsearch/client/DefaultClientConfiguration.java b/src/main/java/org/springframework/data/elasticsearch/client/DefaultClientConfiguration.java index 9afa6d6a9..5f038379e 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/DefaultClientConfiguration.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/DefaultClientConfiguration.java @@ -129,12 +129,6 @@ class DefaultClientConfiguration implements ClientConfiguration { return webClientConfigurer; } - @Deprecated - @Override - public HttpClientConfigCallback getHttpClientConfigurer() { - return httpClientConfigurer; - } - @SuppressWarnings("unchecked") @Override public List> getClientConfigurers() { diff --git a/src/main/java/org/springframework/data/elasticsearch/client/erhlc/ReactiveElasticsearchClient.java b/src/main/java/org/springframework/data/elasticsearch/client/erhlc/ReactiveElasticsearchClient.java index 9d36ba798..9027d2235 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/erhlc/ReactiveElasticsearchClient.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/erhlc/ReactiveElasticsearchClient.java @@ -81,7 +81,9 @@ import org.springframework.web.reactive.function.client.WebClient; * @since 3.2 * @see ClientConfiguration * @see ReactiveRestClients + * @deprecated since 5.0 */ +@Deprecated public interface ReactiveElasticsearchClient { /** diff --git a/src/main/java/org/springframework/data/elasticsearch/client/erhlc/RequestBodyEncodingException.java b/src/main/java/org/springframework/data/elasticsearch/client/erhlc/RequestBodyEncodingException.java index 2fe264ae0..e3e386396 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/erhlc/RequestBodyEncodingException.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/erhlc/RequestBodyEncodingException.java @@ -23,8 +23,10 @@ import org.springframework.web.reactive.function.client.WebClientException; * @author Christoph Strobl * @author Mark Paluch * @since 3.2 + * @deprecated since 5.0 */ -public class RequestBodyEncodingException extends WebClientException { + +@Deprecated public class RequestBodyEncodingException extends WebClientException { private static final long serialVersionUID = 472776714118912855L; diff --git a/src/main/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplate.java b/src/main/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplate.java index 16e80b991..df58a704d 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplate.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplate.java @@ -313,12 +313,6 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper return doDelete(id, routingResolver.getRouting(), index); } - @Override - @Deprecated - final public String delete(String id, @Nullable String routing, IndexCoordinates index) { - return doDelete(id, routing, index); - } - protected abstract String doDelete(String id, @Nullable String routing, IndexCoordinates index); @Override diff --git a/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java b/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java index ced39843e..5a7eb9ebb 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java @@ -245,20 +245,6 @@ public interface DocumentOperations { */ String delete(String id, IndexCoordinates index); - /** - * Delete the one object with provided id. - * - * @param id the document to delete - * @param routing the optional routing for the document to be deleted - * @param index the index from which to delete - * @return documentId of the document deleted - * @since 4.1 - * @deprecated since 4.2, use {@link ElasticsearchOperations#withRouting(RoutingResolver)} and - * {@link #delete(String, IndexCoordinates)} - */ - @Deprecated - String delete(String id, @Nullable String routing, IndexCoordinates index); - /** * Delete the one object with provided id. * diff --git a/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java b/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java index 5a7cc9076..6233e1320 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java @@ -50,16 +50,6 @@ public class SearchHit { @Nullable private final Explanation explanation; private final List matchedQueries = new ArrayList<>(); - /** - * @deprecated since 4.2 use - * {@link #SearchHit(String, String, String, float, Object[], Map, Map, NestedMetaData, Explanation, List, Object)}. - */ - @Deprecated - public SearchHit(@Nullable String index, @Nullable String id, @Nullable String routing, float score, - @Nullable Object[] sortValues, @Nullable Map> highlightFields, T content) { - this(index, id, routing, score, sortValues, highlightFields, null, null, null, null, content); - } - public SearchHit(@Nullable String index, @Nullable String id, @Nullable String routing, float score, @Nullable Object[] sortValues, @Nullable Map> highlightFields, @Nullable Map> innerHits, @Nullable NestedMetaData nestedMetaData, diff --git a/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java b/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java index 9db656197..36ee44d21 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java @@ -157,7 +157,6 @@ final public class ElasticsearchDateConverter { case weekyear: case weekyear_week: case weekyear_week_day: - case custom: continue; } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java index 7c82c1ec7..6708d7c35 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java @@ -157,7 +157,7 @@ public class MappingBuilder { private class InternalBuilder { private boolean writeTypeHints = true; - private List excludeFromSource = new ArrayList<>(); + private final List excludeFromSource = new ArrayList<>(); private String nestedPropertyPrefix = ""; protected String buildPropertyMapping(ElasticsearchPersistentEntity entity, @@ -172,8 +172,11 @@ public class MappingBuilder { // Dynamic templates addDynamicTemplatesMapping(objectNode, entity); - mapEntity(objectNode, entity, true, "", false, FieldType.Auto, null, - entity.findAnnotation(DynamicMapping.class), runtimeFields); + org.springframework.data.elasticsearch.annotations.Document docAnnotation = entity + .findAnnotation(org.springframework.data.elasticsearch.annotations.Document.class); + var dynamicMapping = docAnnotation != null ? docAnnotation.dynamic() : null; + + mapEntity(objectNode, entity, true, "", false, FieldType.Auto, null, dynamicMapping, runtimeFields); if (!excludeFromSource.isEmpty()) { ObjectNode sourceNode = objectNode.putObject(SOURCE); @@ -209,8 +212,8 @@ public class MappingBuilder { private void mapEntity(ObjectNode objectNode, @Nullable ElasticsearchPersistentEntity entity, boolean isRootObject, String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, - @Nullable Field parentFieldAnnotation, @Nullable DynamicMapping dynamicMapping, - @Nullable Document runtimeFields) throws IOException { + @Nullable Field parentFieldAnnotation, @Nullable Dynamic dynamicMapping, @Nullable Document runtimeFields) + throws IOException { if (entity != null && entity.isAnnotationPresent(Mapping.class)) { Mapping mappingAnnotation = entity.getRequiredAnnotation(Mapping.class); @@ -258,8 +261,8 @@ public class MappingBuilder { if (entity != null && entity.dynamic() != Dynamic.INHERIT) { objectNode.put(TYPE_DYNAMIC, entity.dynamic().getMappedName()); - } else if (dynamicMapping != null) { - objectNode.put(TYPE_DYNAMIC, dynamicMapping.value().getMappedName()); + } else if (dynamicMapping != null && dynamicMapping != Dynamic.INHERIT) { + objectNode.put(TYPE_DYNAMIC, dynamicMapping.getMappedName()); } ObjectNode propertiesNode = objectNode.putObject(FIELD_PROPERTIES); @@ -339,7 +342,7 @@ public class MappingBuilder { boolean isCompletionProperty = property.isCompletionProperty(); boolean isNestedOrObjectProperty = isNestedOrObjectProperty(property); - DynamicMapping dynamicMapping = property.findAnnotation(DynamicMapping.class); + Dynamic dynamicMapping = fieldAnnotation != null ? fieldAnnotation.dynamic() : null; if (!isCompletionProperty && property.isEntity() && hasRelevantAnnotation(property)) { @@ -475,7 +478,7 @@ public class MappingBuilder { * @throws IOException */ private void addSingleFieldMapping(ObjectNode propertiesNode, ElasticsearchPersistentProperty property, - Field annotation, boolean nestedOrObjectField, @Nullable DynamicMapping dynamicMapping) throws IOException { + Field annotation, boolean nestedOrObjectField, @Nullable Dynamic dynamicMapping) throws IOException { // build the property json, if empty skip it as this is no valid mapping ObjectNode fieldNode = objectMapper.createObjectNode(); @@ -490,8 +493,8 @@ public class MappingBuilder { if (nestedOrObjectField) { if (annotation.dynamic() != Dynamic.INHERIT) { fieldNode.put(TYPE_DYNAMIC, annotation.dynamic().getMappedName()); - } else if (dynamicMapping != null) { - fieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().getMappedName()); + } else if (dynamicMapping != null && dynamicMapping != Dynamic.INHERIT) { + fieldNode.put(TYPE_DYNAMIC, dynamicMapping.getMappedName()); } } } @@ -531,8 +534,7 @@ public class MappingBuilder { * @throws IOException */ private void addMultiFieldMapping(ObjectNode propertyNode, ElasticsearchPersistentProperty property, - MultiField annotation, boolean nestedOrObjectField, @Nullable DynamicMapping dynamicMapping) - throws IOException { + MultiField annotation, boolean nestedOrObjectField, @Nullable Dynamic dynamicMapping) throws IOException { // main field ObjectNode mainFieldNode = objectMapper.createObjectNode(); @@ -541,8 +543,8 @@ public class MappingBuilder { if (nestedOrObjectField) { if (annotation.mainField().dynamic() != Dynamic.INHERIT) { mainFieldNode.put(TYPE_DYNAMIC, annotation.mainField().dynamic().getMappedName()); - } else if (dynamicMapping != null) { - mainFieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().getMappedName()); + } else if (dynamicMapping != null && dynamicMapping != Dynamic.INHERIT) { + mainFieldNode.put(TYPE_DYNAMIC, dynamicMapping.getMappedName()); } } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java index 145f16a11..20d91e059 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java @@ -244,9 +244,6 @@ public final class MappingParameters { // built-in formats for (DateFormat dateFormat : dateFormats) { - if (dateFormat == DateFormat.none || dateFormat == DateFormat.custom) { - continue; - } formats.add(dateFormat.toString()); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java index 4028efb74..9e3f539a9 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java @@ -395,16 +395,14 @@ public class SimpleElasticsearchPersistentEntity extends BasicPersistentEntit private SettingsParameter buildSettingsParameter(Class clazz) { SettingsParameter settingsParameter = new SettingsParameter(); - Document documentAnnotation = AnnotatedElementUtils.findMergedAnnotation(clazz, Document.class); Setting settingAnnotation = AnnotatedElementUtils.findMergedAnnotation(clazz, Setting.class); - if (documentAnnotation != null) { - settingsParameter.useServerConfiguration = documentAnnotation.useServerConfiguration(); - settingsParameter.shards = documentAnnotation.shards(); - settingsParameter.replicas = documentAnnotation.replicas(); - settingsParameter.refreshIntervall = documentAnnotation.refreshInterval(); - settingsParameter.indexStoreType = documentAnnotation.indexStoreType(); - } + // default values + settingsParameter.useServerConfiguration = false; + settingsParameter.shards = 1; + settingsParameter.replicas = 1; + settingsParameter.refreshIntervall = "1s"; + settingsParameter.indexStoreType = "fs"; if (settingAnnotation != null) { processSettingAnnotation(settingAnnotation, settingsParameter); diff --git a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java index 02fea106f..ecd2cfbc9 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java @@ -261,9 +261,6 @@ public class SimpleElasticsearchPersistentProperty extends // register converters for built-in formats for (DateFormat dateFormat : dateFormats) { switch (dateFormat) { - case none: - case custom: - break; case weekyear: case weekyear_week: case weekyear_week_day: diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepository.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepository.java index 996a16040..85515ab3b 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepository.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepository.java @@ -221,7 +221,7 @@ public class SimpleElasticsearchRepository implements ElasticsearchReposi Assert.notNull(id, "Cannot delete entity with id 'null'."); - doDelete(id, null, getIndexCoordinates()); + doDelete(id, getIndexCoordinates()); } @Override @@ -229,7 +229,7 @@ public class SimpleElasticsearchRepository implements ElasticsearchReposi Assert.notNull(entity, "Cannot delete 'null' entity."); - doDelete(extractIdFromBean(entity), operations.getEntityRouting(entity), getIndexCoordinates()); + doDelete(extractIdFromBean(entity), getIndexCoordinates()); } @Override @@ -269,10 +269,10 @@ public class SimpleElasticsearchRepository implements ElasticsearchReposi deleteAllById(ids); } - private void doDelete(@Nullable ID id, @Nullable String routing, IndexCoordinates indexCoordinates) { + private void doDelete(@Nullable ID id,IndexCoordinates indexCoordinates) { if (id != null) { - executeAndRefresh(operations -> operations.delete(stringIdRepresentation(id), routing, indexCoordinates)); + executeAndRefresh(operations -> operations.delete(stringIdRepresentation(id), indexCoordinates)); } } diff --git a/src/test/java/org/springframework/data/elasticsearch/client/ClientConfigurationUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/client/ClientConfigurationUnitTests.java index 5fa251c74..6298bdd93 100644 --- a/src/test/java/org/springframework/data/elasticsearch/client/ClientConfigurationUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/client/ClientConfigurationUnitTests.java @@ -168,10 +168,10 @@ public class ClientConfigurationUnitTests { ClientConfiguration clientConfiguration = ClientConfiguration.builder() // .connectedTo("foo", "bar") // - .withHttpClientConfigurer(httpClientBuilder -> { + .withClientConfigurer(RestClients.RestClientConfigurationCallback.from(httpClientBuilder -> { callCounter.incrementAndGet(); return httpClientBuilder; - }) // + })) // .build(); ClientConfiguration.ClientConfigurationCallback clientConfigurer = clientConfiguration.getClientConfigurers() @@ -189,10 +189,10 @@ public class ClientConfigurationUnitTests { ClientConfiguration clientConfiguration = ClientConfiguration.builder() // .connectedTo("foo", "bar") // - .withWebClientConfigurer(webClientConfigurer -> { + .withClientConfigurer(ReactiveRestClients.WebClientConfigurationCallback.from(webClient -> { callCounter.incrementAndGet(); - return webClientConfigurer; - }) // + return webClient; + })) // .build(); ClientConfiguration.ClientConfigurationCallback clientConfigurer = clientConfiguration.getClientConfigurers() diff --git a/src/test/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverterUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverterUnitTests.java index 839db6cf8..d6450014d 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverterUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverterUnitTests.java @@ -34,8 +34,6 @@ class ElasticsearchDateConverterUnitTests { void shouldCreateConvertersForAllKnownFormats(DateFormat dateFormat) { switch (dateFormat) { - case none: - case custom: case weekyear: case weekyear_week: case weekyear_week_day: diff --git a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java index 60590cc6b..c8aaef6d9 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java @@ -1730,8 +1730,7 @@ public class MappingElasticsearchConverterUnitTests { @Nullable @Id private String id; @Nullable - @Field(name = "dates", type = FieldType.Date, format = DateFormat.custom, - pattern = "dd.MM.uuuu") private List dates; + @Field(name = "dates", type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") private List dates; @Nullable public String getId() { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java index 33b51ac60..455070009 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java @@ -711,19 +711,15 @@ public abstract class MappingBuilderIntegrationTests extends MappingContextBaseT } } - @Document(indexName = "#{@indexNameProvider.indexName()}") - @DynamicMapping(DynamicMappingValue.False) + @Document(indexName = "#{@indexNameProvider.indexName()}", dynamic = Dynamic.FALSE) static class DynamicMappingAnnotationEntity { @Nullable - @DynamicMapping(DynamicMappingValue.Strict) - @Field(type = FieldType.Object) private Author author; + @Field(type = FieldType.Object, dynamic = Dynamic.STRICT) private Author author; @Nullable - @DynamicMapping(DynamicMappingValue.False) - @Field(type = FieldType.Object) private Map objectMap; + @Field(type = FieldType.Object, dynamic = Dynamic.FALSE) private Map objectMap; @Nullable - @DynamicMapping(DynamicMappingValue.False) - @Field(type = FieldType.Nested) private List> nestedObjectMap; + @Field(type = FieldType.Nested, dynamic = Dynamic.FALSE) private List> nestedObjectMap; @Nullable public Author getAuthor() { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java index 4d2773070..a799130b4 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java @@ -1655,19 +1655,15 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests { @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams; } - @Document(indexName = "test-index-configure-dynamic-mapping") - @DynamicMapping(DynamicMappingValue.False) + @Document(indexName = "test-index-configure-dynamic-mapping", dynamic = Dynamic.FALSE) static class DynamicMappingAnnotationEntity { @Nullable - @DynamicMapping(DynamicMappingValue.Strict) - @Field(type = FieldType.Object) private Author author; + @Field(type = FieldType.Object, dynamic = Dynamic.STRICT) private Author author; @Nullable - @DynamicMapping(DynamicMappingValue.False) - @Field(type = FieldType.Object) private Map objectMap; + @Field(type = FieldType.Object, dynamic = Dynamic.FALSE) private Map objectMap; @Nullable - @DynamicMapping(DynamicMappingValue.False) - @Field(type = FieldType.Nested) private List> nestedObjectMap; + @Field(type = FieldType.Nested, dynamic = Dynamic.FALSE) private List> nestedObjectMap; @Nullable public Author getAuthor() { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java index 54a1757b4..8ea0969a8 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java @@ -315,7 +315,7 @@ public class SimpleElasticsearchPersistentPropertyUnitTests { } static class DateFieldWithCustomFormatAndNoPattern { - @Nullable private @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "") LocalDateTime datetime; + @Nullable private @Field(type = FieldType.Date, format = {}, pattern = "") LocalDateTime datetime; @Nullable public LocalDateTime getDatetime() {