1
0
mirror of synced 2026-08-05 08:26:55 +00:00

Polishing

This commit is contained in:
Peter-Josef Meisch
2026-07-25 15:35:00 +02:00
parent 82be8ffefc
commit becfe765f5
8 changed files with 28 additions and 23 deletions
@@ -6,6 +6,7 @@
* Upgrade to Elasticsearch 9.4.3
* Allow to provide non-standard (custom) index options for `@Field` / `@InnerField`
* Support Elasticsearch Serverless
[[new-features.6-1-0]]
== New in Spring Data Elasticsearch 6.1
@@ -27,9 +27,9 @@ import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPe
/**
* Elasticsearch Setting
*
* @author Steven Pearce
* @author Mohsin Husen
* @author Peter-Josef Meisch
* @author Steven Pearce
*/
@Persistent
@@ -61,8 +61,8 @@ public @interface Setting {
short replicas() default 1;
/**
* Refresh interval for the index. Used for index creation. If no value, defaults are server type dependant and
* set in {@link SimpleElasticsearchPersistentEntity}
* Refresh interval for the index. Used for index creation. If no value, defaults are server type dependant and set in
* {@link SimpleElasticsearchPersistentEntity}
*/
String refreshInterval() default "";
@@ -40,9 +40,9 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* @author Steven Pearce
* @author Christoph Strobl
* @author Peter-Josef Meisch
* @author Steven Pearce
* @since 3.2
*/
@Configuration(proxyBeanMethods = false)
@@ -189,11 +189,13 @@ public class ElasticsearchConfigurationSupport {
}
/**
* Configures the {@link ElasticsearchServerType} to use when creating indexes. The Default value will
* support the standard configurations, and SERVERLESS will support ElasticSearch Serverless
* Configures the {@link ElasticsearchServerType} to use when creating indexes. The Default value will support the
* standard configurations, and SERVERLESS will support ElasticSearch Serverless
*
* @return the {@link ElasticsearchServerType} to use
* @since 6.2
*/
protected ElasticsearchServerType serverType() { return ElasticsearchServerType.DEFAULT; }
protected ElasticsearchServerType serverType() {
return ElasticsearchServerType.DEFAULT;
}
}
@@ -23,6 +23,7 @@ package org.springframework.data.elasticsearch.config;
* @see #SERVERLESS
*
* @author Steven Pearce
* @since 6.2
*/
public enum ElasticsearchServerType {
/**
@@ -40,6 +40,7 @@ import org.springframework.data.mapping.model.FieldNamingStrategy;
* @author Peter-Josef Meisch
* @author Roman Puchkovskiy
* @author Subhobrata Dey
* @author Steven Pearce
*/
public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, ElasticsearchPersistentProperty> {
@@ -28,11 +28,11 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
/**
* SimpleElasticsearchMappingContext
*
* @author Steven Pearce
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Mark Paluch
* @author Peter-Josef Meisch
* @author Steven Pearce
*/
public class SimpleElasticsearchMappingContext
extends AbstractMappingContext<SimpleElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> {
@@ -58,8 +58,6 @@ import org.springframework.util.StringUtils;
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
*
* @param <T>
*
* @author Steven Pearce
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Mark Paluch
@@ -68,6 +66,7 @@ import org.springframework.util.StringUtils;
* @author Peter-Josef Meisch
* @author Roman Puchkovskiy
* @author Subhobrata Dey
* @author Steven Pearce
*/
public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty>
implements ElasticsearchPersistentEntity<T> {
@@ -480,11 +479,10 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
settingsParameter.serverType = contextConfiguration.serverType;
settingsParameter.shards = 1;
settingsParameter.replicas = 1;
settingsParameter.refreshInterval =
switch (contextConfiguration.serverType) {
case DEFAULT -> "1s";
case SERVERLESS -> "5s";
};
settingsParameter.refreshInterval = switch (contextConfiguration.serverType) {
case DEFAULT -> "1s";
case SERVERLESS -> "5s";
};
if (settingAnnotation != null) {
processSettingAnnotation(settingAnnotation, settingsParameter);
@@ -646,7 +644,8 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
this(fieldNamingStrategy, writeTypeHints, ElasticsearchServerType.DEFAULT);
}
ContextConfiguration(FieldNamingStrategy fieldNamingStrategy, boolean writeTypeHints, ElasticsearchServerType serverType) {
ContextConfiguration(FieldNamingStrategy fieldNamingStrategy, boolean writeTypeHints,
ElasticsearchServerType serverType) {
this.fieldNamingStrategy = fieldNamingStrategy;
this.writeTypeHints = writeTypeHints;
this.serverType = serverType;
@@ -52,13 +52,13 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.ReflectionUtils;
/**
* @author Steven Pearce
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Mark Paluch
* @author Oliver Gierke
* @author Peter-Josef Meisch
* @author Roman Puchkovskiy
* @author Steven Pearce
*/
public class SimpleElasticsearchPersistentEntityTests extends MappingContextBaseTests {
@@ -244,8 +244,8 @@ public class SimpleElasticsearchPersistentEntityTests extends MappingContextBase
Settings settings = entity.getDefaultSettings().flatten();
assertThat(settings).containsEntry("index.number_of_shards", "1");
assertThat(settings).containsEntry("index.number_of_replicas","1");
assertThat(settings).containsEntry("index.refresh_interval","1s");
assertThat(settings).containsEntry("index.number_of_replicas", "1");
assertThat(settings).containsEntry("index.refresh_interval", "1s");
}
@@ -258,8 +258,8 @@ public class SimpleElasticsearchPersistentEntityTests extends MappingContextBase
Settings settings = entity.getDefaultSettings().flatten();
assertThat(settings).containsEntry("index.number_of_shards", "4");
assertThat(settings).containsEntry("index.number_of_replicas","5");
assertThat(settings).containsEntry("index.refresh_interval","1s");
assertThat(settings).containsEntry("index.number_of_replicas", "5");
assertThat(settings).containsEntry("index.refresh_interval", "1s");
}
@@ -317,7 +317,7 @@ public class SimpleElasticsearchPersistentEntityTests extends MappingContextBase
Settings settings = entity.getDefaultSettings().flatten();
assertThat(settings).doesNotContainKey("index.number_of_shards");
assertThat(settings).doesNotContainKey("index.number_of_replicas");
assertThat(settings).containsEntry("index.refresh_interval","5s");
assertThat(settings).containsEntry("index.refresh_interval", "5s");
}
@@ -332,7 +332,7 @@ public class SimpleElasticsearchPersistentEntityTests extends MappingContextBase
assertThat(settings).doesNotContainKey("index.number_of_shards");
assertThat(settings).doesNotContainKey("index.number_of_replicas");
assertThat(settings).containsEntry("index.refresh_interval","5s");
assertThat(settings).containsEntry("index.refresh_interval", "5s");
}
}
@@ -437,6 +437,7 @@ public class SimpleElasticsearchPersistentEntityTests extends MappingContextBase
assertThat(persistentEntity.getServerType()).isEqualTo(ElasticsearchServerType.SERVERLESS);
assertThat(persistentEntity.getRefreshInterval()).isEqualTo("9s");
}
@Test
@DisplayName("should return OverriddenRefreshInterval from SERVERLESS context configuration")
void shouldReturnOverriddenRefreshIntervalFromSERVERLESSContextConfiguration() {