diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/CompletionContext.java b/src/main/java/org/springframework/data/elasticsearch/annotations/CompletionContext.java
index f510a3d9b..4790a6bbf 100644
--- a/src/main/java/org/springframework/data/elasticsearch/annotations/CompletionContext.java
+++ b/src/main/java/org/springframework/data/elasticsearch/annotations/CompletionContext.java
@@ -46,6 +46,16 @@
* @since 4.3
*/
enum ContextMappingType {
- CATEGORY, GEO
+ CATEGORY("category"), GEO("geo");
+
+ private final String mappedName;
+
+ ContextMappingType(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ public String getMappedName() {
+ return mappedName;
+ }
}
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java b/src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java
index a0bd128f9..164c1a528 100644
--- a/src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java
+++ b/src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java
@@ -17,7 +17,7 @@
/**
* Values for the {@code dynamic} mapping parameter.
- *
+ *
* @author Sascha Woo
* @since 4.3
*/
@@ -25,26 +25,36 @@ public enum Dynamic {
/**
* New fields are added to the mapping.
*/
- TRUE,
+ TRUE("true"),
/**
* New fields are added to the mapping as
* runtime fields. These
* fields are not indexed, and are loaded from {@code _source} at query time.
*/
- RUNTIME,
+ RUNTIME("runtime"),
/**
* New fields are ignored. These fields will not be indexed or searchable, but will still appear in the
* {@code _source} field of returned hits. These fields will not be added to the mapping, and new fields must be added
* explicitly.
*/
- FALSE,
+ FALSE("false"),
/**
* If new fields are detected, an exception is thrown and the document is rejected. New fields must be explicitly
* added to the mapping.
*/
- STRICT,
+ STRICT("strict"),
/**
* Inherit the dynamic setting from their parent object or from the mapping type.
*/
- INHERIT
+ INHERIT("nherit");
+
+ private final String mappedName;
+
+ Dynamic(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ public String getMappedName() {
+ return mappedName;
+ }
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java b/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java
index 85fe3b8e8..c3679f62b 100644
--- a/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java
+++ b/src/main/java/org/springframework/data/elasticsearch/annotations/DynamicMappingValue.java
@@ -17,13 +17,23 @@
/**
* 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 since 4.3, use {@link Document#dynamic()} or {@link Field#dynamic()} instead.
*/
@Deprecated
public enum DynamicMappingValue {
- True, False, Strict
+ 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/FieldType.java b/src/main/java/org/springframework/data/elasticsearch/annotations/FieldType.java
index 80c283841..1488496eb 100644
--- a/src/main/java/org/springframework/data/elasticsearch/annotations/FieldType.java
+++ b/src/main/java/org/springframework/data/elasticsearch/annotations/FieldType.java
@@ -26,40 +26,51 @@
* @author Morgan Lutz
*/
public enum FieldType {
- Auto, //
- Text, //
- Keyword, //
- Long, //
- Integer, //
- Short, //
- Byte, //
- Double, //
- Float, //
- Half_Float, //
- Scaled_Float, //
- Date, //
- Date_Nanos, //
- Boolean, //
- Binary, //
- Integer_Range, //
- Float_Range, //
- Long_Range, //
- Double_Range, //
- Date_Range, //
- Ip_Range, //
- Object, //
- Nested, //
- Ip, //
- TokenCount, //
- Percolator, //
- Flattened, //
- Search_As_You_Type, //
+ Auto("auto"), //
+ Text("text"), //
+ Keyword("keyword"), //
+ Long("long"), //
+ Integer("integer"), //
+ Short("short"), //
+ Byte("byte"), //
+ Double("double"), //
+ Float("float"), //
+ Half_Float("half_float"), //
+ Scaled_Float("scaled_float"), //
+ Date("date"), //
+ Date_Nanos("date_nanos"), //
+ Boolean("boolean"), //
+ Binary("binary"), //
+ Integer_Range("integer_range"), //
+ Float_Range("float_range"), //
+ Long_Range("long_range"), //
+ Double_Range("double_range"), //
+ Date_Range("date_range"), //
+ Ip_Range("ip_range"), //
+ Object("object"), //
+ Nested("nested"), //
+ Ip("ip"), //
+ TokenCount("token_count"), //
+ Percolator("percolator"), //
+ Flattened("flattened"), //
+ Search_As_You_Type("search_as_you_type"), //
/** @since 4.1 */
- Rank_Feature, //
+ Rank_Feature("rank_feature"), //
/** @since 4.1 */
- Rank_Features, //
+ Rank_Features("rank_features"), //
/** since 4.2 */
- Wildcard, //
+ Wildcard("wildcard"), //
/** @since 4.2 */
- Dense_Vector //
+ Dense_Vector("dense_vector") //
+ ;
+
+ private final String mappedName;
+
+ FieldType(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ public String getMappedName() {
+ return mappedName;
+ }
}
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 a30726ef5..847f61160 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
@@ -230,8 +230,7 @@ private void mapEntity(ObjectNode objectNode, @Nullable ElasticsearchPersistentE
boolean writeNestedProperties = !isRootObject && (isAnyPropertyAnnotatedWithField(entity) || nestedOrObjectField);
if (writeNestedProperties) {
- String type = nestedOrObjectField ? fieldType.toString().toLowerCase()
- : FieldType.Object.toString().toLowerCase();
+ String type = nestedOrObjectField ? fieldType.getMappedName() : FieldType.Object.getMappedName();
ObjectNode nestedObjectNode = objectMapper.createObjectNode();
nestedObjectNode.put(FIELD_PARAM_TYPE, type);
@@ -247,9 +246,9 @@ private void mapEntity(ObjectNode objectNode, @Nullable ElasticsearchPersistentE
}
if (entity != null && entity.dynamic() != Dynamic.INHERIT) {
- objectNode.put(TYPE_DYNAMIC, entity.dynamic().name().toLowerCase());
+ objectNode.put(TYPE_DYNAMIC, entity.dynamic().getMappedName());
} else if (dynamicMapping != null) {
- objectNode.put(TYPE_DYNAMIC, dynamicMapping.value().name().toLowerCase());
+ objectNode.put(TYPE_DYNAMIC, dynamicMapping.value().getMappedName());
}
ObjectNode propertiesNode = objectNode.putObject(FIELD_PROPERTIES);
@@ -418,7 +417,7 @@ private void applyCompletionFieldMapping(ObjectNode propertyNode, ElasticsearchP
ObjectNode contextNode = contextsNode.addObject();
contextNode.put(FIELD_CONTEXT_NAME, context.name());
- contextNode.put(FIELD_CONTEXT_TYPE, context.type().name().toLowerCase());
+ contextNode.put(FIELD_CONTEXT_TYPE, context.type().getMappedName());
if (context.precision().length() > 0) {
contextNode.put(FIELD_CONTEXT_PRECISION, context.precision());
@@ -450,7 +449,7 @@ private void applyDisabledPropertyMapping(ObjectNode propertiesNode, Elasticsear
}
propertiesNode.set(property.getFieldName(), objectMapper.createObjectNode() //
- .put(FIELD_PARAM_TYPE, field.type().name().toLowerCase()) //
+ .put(FIELD_PARAM_TYPE, field.type().getMappedName()) //
.put(MAPPING_ENABLED, false) //
);
@@ -479,9 +478,9 @@ private void addSingleFieldMapping(ObjectNode propertiesNode, ElasticsearchPersi
if (nestedOrObjectField) {
if (annotation.dynamic() != Dynamic.INHERIT) {
- fieldNode.put(TYPE_DYNAMIC, annotation.dynamic().name().toLowerCase());
+ fieldNode.put(TYPE_DYNAMIC, annotation.dynamic().getMappedName());
} else if (dynamicMapping != null) {
- fieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().name().toLowerCase());
+ fieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().getMappedName());
}
}
}
@@ -530,9 +529,9 @@ private void addMultiFieldMapping(ObjectNode propertyNode, ElasticsearchPersiste
if (nestedOrObjectField) {
if (annotation.mainField().dynamic() != Dynamic.INHERIT) {
- mainFieldNode.put(TYPE_DYNAMIC, annotation.mainField().dynamic().name().toLowerCase());
+ mainFieldNode.put(TYPE_DYNAMIC, annotation.mainField().dynamic().getMappedName());
} else if (dynamicMapping != null) {
- mainFieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().name().toLowerCase());
+ mainFieldNode.put(TYPE_DYNAMIC, dynamicMapping.value().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 0f6b80795..c2f196df7 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
@@ -237,7 +237,7 @@ public void writeTypeAndParametersTo(ObjectNode objectNode) throws IOException {
}
if (type != FieldType.Auto) {
- objectNode.put(FIELD_PARAM_TYPE, type.toString().toLowerCase());
+ objectNode.put(FIELD_PARAM_TYPE, type.getMappedName());
if (type == FieldType.Date) {
List formats = new ArrayList<>();
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 7ac0fd054..312f7a5b5 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
@@ -38,12 +38,18 @@
import java.util.Set;
import org.assertj.core.data.Percentage;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
+import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQuery;
+import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.MappingContextBaseTests;
@@ -51,12 +57,11 @@
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
-import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQuery;
-import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
import org.springframework.data.elasticsearch.core.suggest.Completion;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
+import org.springframework.data.elasticsearch.utils.IndexNameProvider;
import org.springframework.data.geo.Box;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Point;
@@ -79,10 +84,25 @@
* @author Morgan Lutz
*/
@SpringIntegrationTest
-@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class })
+@ContextConfiguration(classes = { MappingBuilderIntegrationTests.Config.class })
public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
+ @Configuration
+ @Import({ ElasticsearchRestTemplateConfiguration.class })
+ static class Config {
+ @Bean
+ IndexNameProvider indexNameProvider() {
+ return new IndexNameProvider("mapping-builder");
+ }
+ }
+
@Autowired private ElasticsearchOperations operations;
+ @Autowired IndexNameProvider indexNameProvider;
+
+ @BeforeEach
+ public void before() {
+ indexNameProvider.increment();
+ }
@Test
@Order(java.lang.Integer.MAX_VALUE)
@@ -132,8 +152,7 @@ public void shouldAddStockPriceDocumentToIndex() {
@Test // DATAES-76
public void shouldAddSampleInheritedEntityDocumentToIndex() {
// given
- IndexCoordinates index = IndexCoordinates.of("test-index-sample-inherited-mapping-builder");
- IndexOperations indexOps = operations.indexOps(index);
+ IndexOperations indexOps = operations.indexOps(SampleInheritedEntity.class);
// when
indexOps.create();
@@ -142,11 +161,10 @@ public void shouldAddSampleInheritedEntityDocumentToIndex() {
String message = "msg";
String id = "abc";
operations.index(new SampleInheritedEntityBuilder(id).createdDate(createdDate).message(message).buildIndex(),
- index);
- operations.indexOps(SampleInheritedEntity.class).refresh();
+ IndexCoordinates.of(indexNameProvider.indexName()));
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
- SearchHits result = operations.search(searchQuery, SampleInheritedEntity.class, index);
+ SearchHits result = operations.search(searchQuery, SampleInheritedEntity.class);
// then
assertThat(result).hasSize(1);
@@ -163,7 +181,7 @@ public void shouldHandleReverseRelationship() {
IndexOperations indexOpsUser = operations.indexOps(User.class);
indexOpsUser.create();
indexOpsUser.putMapping(User.class);
-
+ indexNameProvider.increment();
IndexOperations indexOpsGroup = operations.indexOps(Group.class);
indexOpsGroup.create();
indexOpsGroup.putMapping(Group.class);
@@ -336,11 +354,19 @@ void shouldWriteSourceExcludes() {
}
+ @Test // #2024
+ @DisplayName("should map all field type values")
+ void shouldMapAllFieldTypeValues() {
+ operations.indexOps(EntityWithAllTypes.class).createWithMapping();
+ }
+
// region entities
- @Document(indexName = "ignore-above-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class IgnoreAboveEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message;
@Nullable
public String getId() {
@@ -365,57 +391,76 @@ static class FieldNameEntity {
@Document(indexName = "fieldname-index")
static class IdEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class TextEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
@Field(name = "text-property", type = FieldType.Text) //
@Nullable private String textProperty;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class MappingEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
- @Field("mapping-property") @Mapping(mappingPath = "/mappings/test-field-analyzed-mappings.json") //
+ @Field("mapping-property")
+ @Mapping(mappingPath = "/mappings/test-field-analyzed-mappings.json") //
@Nullable private byte[] mappingProperty;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class GeoPointEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
- @Nullable @Field("geopoint-property") private GeoPoint geoPoint;
+ @Nullable
+ @Field("geopoint-property") private GeoPoint geoPoint;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class CircularEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
- @Nullable @Field(name = "circular-property", type = FieldType.Object, ignoreFields = { "circular-property" }) //
+ @Nullable
+ @Field(name = "circular-property", type = FieldType.Object, ignoreFields = { "circular-property" }) //
private CircularEntity circularProperty;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class CompletionEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
- @Nullable @Field("completion-property") @CompletionField(maxInputLength = 100) //
+ @Nullable
+ @Field("completion-property")
+ @CompletionField(maxInputLength = 100) //
private Completion suggest;
}
- @Document(indexName = "fieldname-index")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class MultiFieldEntity {
- @Nullable @Id @Field("id-property") private String id;
+ @Nullable
+ @Id
+ @Field("id-property") private String id;
@Nullable //
@MultiField(mainField = @Field(name = "main-field", type = FieldType.Text, analyzer = "whitespace"),
@@ -425,13 +470,17 @@ static class MultiFieldEntity {
}
}
- @Document(indexName = "test-index-book-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class Book {
- @Nullable @Id private String id;
+ @Nullable
+ @Id private String id;
@Nullable private String name;
- @Nullable @Field(type = FieldType.Object) private Author author;
- @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
- @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
+ @Nullable
+ @Field(type = FieldType.Object) private Author author;
+ @Nullable
+ @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
+ @Nullable
+ @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
searchAnalyzer = "standard") }) private String description;
@@ -481,11 +530,12 @@ public void setDescription(@Nullable String description) {
}
}
- @Document(indexName = "test-index-simple-recursive-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class SimpleRecursiveEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Object,
- ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Object, ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
@Nullable
public String getId() {
@@ -506,12 +556,16 @@ public void setCircularObject(@Nullable SimpleRecursiveEntity circularObject) {
}
}
- @Document(indexName = "test-copy-to-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class CopyToEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
- @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
- @Nullable @Field(type = FieldType.Keyword) private String name;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Keyword, copyTo = "name") private String firstName;
+ @Nullable
+ @Field(type = FieldType.Keyword, copyTo = "name") private String lastName;
+ @Nullable
+ @Field(type = FieldType.Keyword) private String name;
@Nullable
public String getId() {
@@ -550,12 +604,15 @@ public void setName(@Nullable String name) {
}
}
- @Document(indexName = "test-index-normalizer-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
@Setting(settingPath = "/settings/test-normalizer.json")
static class NormalizerEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
- @Nullable @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name;
+ @Nullable
+ @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case",
type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description;
@Nullable
@@ -610,10 +667,11 @@ public void setName(String name) {
}
}
- @Document(indexName = "test-index-sample-inherited-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class SampleInheritedEntity extends AbstractInheritedEntity {
- @Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
+ @Nullable
+ @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
@Nullable
public String getMessage() {
@@ -656,11 +714,13 @@ public IndexQuery buildIndex() {
}
}
- @Document(indexName = "test-index-stock-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class StockPrice {
- @Nullable @Id private String id;
+ @Nullable
+ @Id private String id;
@Nullable private String symbol;
- @Nullable @Field(type = FieldType.Double) private BigDecimal price;
+ @Nullable
+ @Field(type = FieldType.Double) private BigDecimal price;
@Nullable
public String getId() {
@@ -691,8 +751,10 @@ public void setPrice(@Nullable BigDecimal price) {
}
static class AbstractInheritedEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Date, format = DateFormat.date_time, index = false) private Date createdDate;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Date, format = DateFormat.date_time, index = false) private Date createdDate;
@Nullable
public String getId() {
@@ -713,21 +775,27 @@ public void setCreatedDate(Date createdDate) {
}
}
- @Document(indexName = "test-index-geo-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class GeoEntity {
- @Nullable @Id private String id;
+ @Nullable
+ @Id private String id;
// geo shape - Spring Data
@Nullable private Box box;
@Nullable private Circle circle;
@Nullable private Polygon polygon;
// geo point - Custom implementation + Spring Data
- @Nullable @GeoPointField private Point pointA;
+ @Nullable
+ @GeoPointField private Point pointA;
@Nullable private GeoPoint pointB;
- @Nullable @GeoPointField private String pointC;
- @Nullable @GeoPointField private double[] pointD;
+ @Nullable
+ @GeoPointField private String pointC;
+ @Nullable
+ @GeoPointField private double[] pointD;
// geo shape, until e have the classes for this, us a strng
- @Nullable @GeoShapeField private String shape1;
- @Nullable @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
+ @Nullable
+ @GeoShapeField private String shape1;
+ @Nullable
+ @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false,
orientation = GeoShapeField.Orientation.clockwise) private String shape2;
@Nullable
@@ -821,17 +889,21 @@ public void setShape2(@Nullable String shape2) {
}
}
- @Document(indexName = "test-index-user-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
+
static class User {
- @Nullable @Id private String id;
+ @Nullable
+ @Id private String id;
@Field(type = FieldType.Nested, ignoreFields = { "users" }) private Set groups = new HashSet<>();
}
- @Document(indexName = "test-index-group-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
+
static class Group {
- @Nullable @Id String id;
+ @Nullable
+ @Id String id;
@Field(type = FieldType.Nested, ignoreFields = { "groups" }) private Set users = new HashSet<>();
}
@@ -848,11 +920,14 @@ public String getValue() {
}
}
- @Document(indexName = "completion")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
+
static class CompletionDocument {
- @Nullable @Id private String id;
- @Nullable @CompletionField(contexts = { @CompletionContext(name = "location",
- type = CompletionContext.ContextMappingType.GEO, path = "proppath") }) private Completion suggest;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @CompletionField(contexts = { @CompletionContext(name = "location", type = CompletionContext.ContextMappingType.GEO,
+ path = "proppath") }) private Completion suggest;
@Nullable
public String getId() {
@@ -873,9 +948,10 @@ public void setSuggest(@Nullable Completion suggest) {
}
}
- @Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class EntityWithSeqNoPrimaryTerm {
- @Nullable @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
+ @Nullable
+ @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
@Nullable
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
@@ -888,10 +964,14 @@ public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
}
static class RankFeatureEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Rank_Feature) private Integer pageRank;
- @Nullable @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
- @Nullable @Field(type = FieldType.Rank_Features) private Map topics;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Rank_Feature) private Integer pageRank;
+ @Nullable
+ @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
+ @Nullable
+ @Field(type = FieldType.Rank_Features) private Map topics;
@Nullable
public String getId() {
@@ -930,18 +1010,25 @@ public void setTopics(@Nullable Map topics) {
}
}
- @Document(indexName = "termvectors-test")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class TermVectorFieldEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = FieldType.Text, termVector = TermVector.no) private String no;
- @Nullable @Field(type = FieldType.Text, termVector = TermVector.yes) private String yes;
- @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions;
- @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets;
- @Nullable @Field(type = FieldType.Text,
- termVector = TermVector.with_positions_offsets) private String with_positions_offsets;
- @Nullable @Field(type = FieldType.Text,
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = FieldType.Text, termVector = TermVector.no) private String no;
+ @Nullable
+ @Field(type = FieldType.Text, termVector = TermVector.yes) private String yes;
+ @Nullable
+ @Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions;
+ @Nullable
+ @Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets;
+ @Nullable
+ @Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets) private String with_positions_offsets;
+ @Nullable
+ @Field(type = FieldType.Text,
termVector = TermVector.with_positions_payloads) private String with_positions_payloads;
- @Nullable @Field(type = FieldType.Text,
+ @Nullable
+ @Field(type = FieldType.Text,
termVector = TermVector.with_positions_offsets_payloads) private String with_positions_offsets_payloads;
@Nullable
@@ -1017,10 +1104,12 @@ public void setWith_positions_offsets_payloads(@Nullable String with_positions_o
}
}
- @Document(indexName = "wildcard-test")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class WildcardEntity {
- @Nullable @Field(type = Wildcard) private String wildcardWithoutParams;
- @Nullable @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams;
+ @Nullable
+ @Field(type = Wildcard) private String wildcardWithoutParams;
+ @Nullable
+ @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams;
@Nullable
public String getWildcardWithoutParams() {
@@ -1041,11 +1130,13 @@ public void setWildcardWithParams(@Nullable String wildcardWithParams) {
}
}
- @Document(indexName = "disabled-entity-mapping")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
@Mapping(enabled = false)
static class DisabledMappingEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = Text) private String text;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = Text) private String text;
@Nullable
public String getId() {
@@ -1068,9 +1159,13 @@ public void setText(@Nullable String text) {
@Document(indexName = "disabled-property-mapping")
static class DisabledMappingProperty {
- @Nullable @Id private String id;
- @Nullable @Field(type = Text) private String text;
- @Nullable @Mapping(enabled = false) @Field(type = Object) private Object object;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = Text) private String text;
+ @Nullable
+ @Mapping(enabled = false)
+ @Field(type = Object) private Object object;
@Nullable
public String getId() {
@@ -1100,10 +1195,12 @@ public void setObject(@Nullable java.lang.Object object) {
}
}
- @Document(indexName = "densevector-test")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
static class DenseVectorEntity {
- @Nullable @Id private String id;
- @Nullable @Field(type = Dense_Vector, dims = 3) private float[] dense_vector;
+ @Nullable
+ @Id private String id;
+ @Nullable
+ @Field(type = Dense_Vector, dims = 3) private float[] dense_vector;
@Nullable
public String getId() {
@@ -1124,15 +1221,19 @@ public void setDense_vector(@Nullable float[] dense_vector) {
}
}
- @Document(indexName = "dynamic-mapping-annotation")
+ @Document(indexName = "#{@indexNameProvider.indexName()}")
@DynamicMapping(DynamicMappingValue.False)
static class DynamicMappingAnnotationEntity {
- @Nullable @DynamicMapping(DynamicMappingValue.Strict) @Field(type = FieldType.Object) private Author author;
- @Nullable @DynamicMapping(DynamicMappingValue.False) @Field(
- type = FieldType.Object) private Map objectMap;
- @Nullable @DynamicMapping(DynamicMappingValue.False) @Field(
- type = FieldType.Nested) private List