Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b3ecf6b23 | |||
| b96b5c2322 | |||
| 2a646e583d | |||
| 09c76b4694 | |||
| 1b59b31a72 | |||
| 2aba7a57fb | |||
| 15ca49a92e | |||
| b7088f8002 | |||
| 76f7ed5196 |
@@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-elasticsearch</artifactId>
|
||||
<version>4.2.7</version>
|
||||
<version>4.2.8</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>2.5.7</version>
|
||||
<version>2.5.8</version>
|
||||
</parent>
|
||||
|
||||
<name>Spring Data Elasticsearch</name>
|
||||
@@ -20,9 +20,9 @@
|
||||
<properties>
|
||||
<commonslang>2.6</commonslang>
|
||||
<elasticsearch>7.12.1</elasticsearch>
|
||||
<log4j>2.13.3</log4j>
|
||||
<log4j>2.17.0</log4j>
|
||||
<netty>4.1.52.Final</netty>
|
||||
<springdata.commons>2.5.7</springdata.commons>
|
||||
<springdata.commons>2.5.8</springdata.commons>
|
||||
<testcontainers>1.15.1</testcontainers>
|
||||
<java-module-name>spring.data.elasticsearch</java-module-name>
|
||||
</properties>
|
||||
@@ -152,6 +152,12 @@
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>transport</artifactId>
|
||||
<version>${elasticsearch}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -159,6 +165,12 @@
|
||||
<groupId>org.elasticsearch.plugin</groupId>
|
||||
<artifactId>transport-netty4-client</artifactId>
|
||||
<version>${elasticsearch}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -272,24 +284,24 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.openwebbeans.test</groupId>
|
||||
<artifactId>cditest-owb</artifactId>
|
||||
<version>1.2.8</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
-->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.openwebbeans.test</groupId>
|
||||
<artifactId>cditest-owb</artifactId>
|
||||
<version>1.2.8</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-atinject_1.0_spec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.skyscreamer</groupId>
|
||||
@@ -467,7 +479,9 @@
|
||||
</module>
|
||||
</checkstyleRules>
|
||||
<includes>**/*</includes>
|
||||
<excludes>.git/**/*,target/**/*,**/target/**/*,.idea/**/*,**/spring.schemas,**/*.svg,mvnw,mvnw.cmd,**/*.policy</excludes>
|
||||
<excludes>
|
||||
.git/**/*,target/**/*,**/target/**/*,.idea/**/*,**/spring.schemas,**/*.svg,mvnw,mvnw.cmd,**/*.policy
|
||||
</excludes>
|
||||
<sourceDirectories>./</sourceDirectories>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
+12
-2
@@ -17,10 +17,20 @@ package org.springframework.data.elasticsearch.annotations;
|
||||
|
||||
/**
|
||||
* values for the {@link DynamicMapping annotation}
|
||||
*
|
||||
*
|
||||
* @author Peter-Josef Meisch
|
||||
* @since 4.0
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,40 +26,51 @@ package org.springframework.data.elasticsearch.annotations;
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
|
||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
import org.springframework.data.elasticsearch.core.document.NestedMetaData;
|
||||
@@ -44,12 +43,11 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @author Roman Puchkovskiy
|
||||
* @author Matt Gilene
|
||||
* @author Sascha Woo
|
||||
* @since 4.0
|
||||
*/
|
||||
class SearchHitMapping<T> {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SearchHitMapping.class);
|
||||
|
||||
private final Class<T> type;
|
||||
private final ElasticsearchConverter converter;
|
||||
private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
||||
@@ -173,7 +171,7 @@ class SearchHitMapping<T> {
|
||||
*/
|
||||
private SearchHits<?> mapInnerDocuments(SearchHits<SearchDocument> searchHits, Class<T> type) {
|
||||
|
||||
if (searchHits.getTotalHits() == 0) {
|
||||
if (searchHits.isEmpty()) {
|
||||
return searchHits;
|
||||
}
|
||||
|
||||
@@ -217,7 +215,7 @@ class SearchHitMapping<T> {
|
||||
searchHits.getAggregations());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Could not map inner_hits", e);
|
||||
throw new UncategorizedElasticsearchException("Unable to convert inner hits.", e);
|
||||
}
|
||||
|
||||
return searchHits;
|
||||
|
||||
@@ -156,10 +156,9 @@ public class MappingBuilder {
|
||||
boolean writeNestedProperties = !isRootObject && (isAnyPropertyAnnotatedWithField(entity) || nestedOrObjectField);
|
||||
if (writeNestedProperties) {
|
||||
|
||||
String type = nestedOrObjectField ? fieldType.toString().toLowerCase()
|
||||
: FieldType.Object.toString().toLowerCase();
|
||||
builder.startObject(nestedObjectFieldName).field(FIELD_PARAM_TYPE, type);
|
||||
String type = nestedOrObjectField ? fieldType.getMappedName() : FieldType.Object.getMappedName();
|
||||
|
||||
builder.startObject(nestedObjectFieldName).field(FIELD_PARAM_TYPE, type);
|
||||
if (nestedOrObjectField && FieldType.Nested == fieldType && parentFieldAnnotation != null
|
||||
&& parentFieldAnnotation.includeInParent()) {
|
||||
builder.field("include_in_parent", true);
|
||||
@@ -364,7 +363,7 @@ public class MappingBuilder {
|
||||
}
|
||||
|
||||
builder.startObject(property.getFieldName()) //
|
||||
.field(FIELD_PARAM_TYPE, field.type().name().toLowerCase()) //
|
||||
.field(FIELD_PARAM_TYPE, field.type().getMappedName()) //
|
||||
.field(MAPPING_ENABLED, false) //
|
||||
.endObject(); //
|
||||
} catch (Exception e) {
|
||||
@@ -392,7 +391,7 @@ public class MappingBuilder {
|
||||
builder.startObject(property.getFieldName());
|
||||
|
||||
if (nestedOrObjectField && dynamicMapping != null) {
|
||||
builder.field(TYPE_DYNAMIC, dynamicMapping.value().name().toLowerCase());
|
||||
builder.field(TYPE_DYNAMIC, dynamicMapping.value().getMappedName());
|
||||
}
|
||||
|
||||
addFieldMappingParameters(builder, annotation, nestedOrObjectField);
|
||||
@@ -441,7 +440,7 @@ public class MappingBuilder {
|
||||
builder.startObject(property.getFieldName());
|
||||
|
||||
if (nestedOrObjectField && dynamicMapping != null) {
|
||||
builder.field(TYPE_DYNAMIC, dynamicMapping.value().name().toLowerCase());
|
||||
builder.field(TYPE_DYNAMIC, dynamicMapping.value().getMappedName());
|
||||
}
|
||||
|
||||
addFieldMappingParameters(builder, annotation.mainField(), nestedOrObjectField);
|
||||
|
||||
+7
-5
@@ -71,7 +71,7 @@ public final class MappingParameters {
|
||||
static final String FIELD_PARAM_NULL_VALUE = "null_value";
|
||||
static final String FIELD_PARAM_POSITION_INCREMENT_GAP = "position_increment_gap";
|
||||
static final String FIELD_PARAM_POSITIVE_SCORE_IMPACT = "positive_score_impact";
|
||||
static final String FIELD_PARAM_DIMS = "dims";
|
||||
static final String FIELD_PARAM_DIMS = "dims";
|
||||
static final String FIELD_PARAM_SCALING_FACTOR = "scaling_factor";
|
||||
static final String FIELD_PARAM_SEARCH_ANALYZER = "search_analyzer";
|
||||
static final String FIELD_PARAM_STORE = "store";
|
||||
@@ -101,7 +101,7 @@ public final class MappingParameters {
|
||||
private final NullValueType nullValueType;
|
||||
private final Integer positionIncrementGap;
|
||||
private final boolean positiveScoreImpact;
|
||||
private final Integer dims;
|
||||
private final Integer dims;
|
||||
private final String searchAnalyzer;
|
||||
private final double scalingFactor;
|
||||
private final Similarity similarity;
|
||||
@@ -163,7 +163,8 @@ public final class MappingParameters {
|
||||
positiveScoreImpact = field.positiveScoreImpact();
|
||||
dims = field.dims();
|
||||
if (type == FieldType.Dense_Vector) {
|
||||
Assert.isTrue(dims >= 1 && dims <= 2048, "Invalid required parameter! Dense_Vector value \"dims\" must be between 1 and 2048.");
|
||||
Assert.isTrue(dims >= 1 && dims <= 2048,
|
||||
"Invalid required parameter! Dense_Vector value \"dims\" must be between 1 and 2048.");
|
||||
}
|
||||
Assert.isTrue(field.enabled() || type == FieldType.Object, "enabled false is only allowed for field type object");
|
||||
enabled = field.enabled();
|
||||
@@ -205,7 +206,8 @@ public final class MappingParameters {
|
||||
positiveScoreImpact = field.positiveScoreImpact();
|
||||
dims = field.dims();
|
||||
if (type == FieldType.Dense_Vector) {
|
||||
Assert.isTrue(dims >= 1 && dims <= 2048, "Invalid required parameter! Dense_Vector value \"dims\" must be between 1 and 2048.");
|
||||
Assert.isTrue(dims >= 1 && dims <= 2048,
|
||||
"Invalid required parameter! Dense_Vector value \"dims\" must be between 1 and 2048.");
|
||||
}
|
||||
enabled = true;
|
||||
eagerGlobalOrdinals = field.eagerGlobalOrdinals();
|
||||
@@ -229,7 +231,7 @@ public final class MappingParameters {
|
||||
}
|
||||
|
||||
if (type != FieldType.Auto) {
|
||||
builder.field(FIELD_PARAM_TYPE, type.name().toLowerCase());
|
||||
builder.field(FIELD_PARAM_TYPE, type.getMappedName());
|
||||
|
||||
if (type == FieldType.Date) {
|
||||
List<String> formats = new ArrayList<>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data Elasticsearch 4.2.7 (2021.0.7)
|
||||
Spring Data Elasticsearch 4.2.8 (2021.0.8)
|
||||
Copyright (c) [2013-2021] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -32,5 +32,6 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+43
@@ -50,10 +50,13 @@ import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.query.InnerHitBuilder;
|
||||
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.join.query.HasChildQueryBuilder;
|
||||
import org.elasticsearch.join.query.JoinQueryBuilders;
|
||||
import org.elasticsearch.join.query.ParentIdQueryBuilder;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
@@ -3029,6 +3032,46 @@ public abstract class ElasticsearchTemplateTests {
|
||||
indexOperations.removeAlias(aliasQuery);
|
||||
}
|
||||
|
||||
@Test // #1997
|
||||
@DisplayName("should return document with inner hits size zero")
|
||||
void shouldReturnDocumentWithInnerHitsSizeZero() {
|
||||
|
||||
// given
|
||||
SampleJoinEntity sampleQuestionEntity1 = new SampleJoinEntity();
|
||||
sampleQuestionEntity1.setUuid("q1");
|
||||
sampleQuestionEntity1.setText("This is a question");
|
||||
sampleQuestionEntity1.setMyJoinField(new JoinField<>("question"));
|
||||
|
||||
SampleJoinEntity sampleAnswerEntity1 = new SampleJoinEntity();
|
||||
sampleAnswerEntity1.setUuid("a1");
|
||||
sampleAnswerEntity1.setText("This is an answer");
|
||||
sampleAnswerEntity1.setMyJoinField(new JoinField<>("answer", sampleQuestionEntity1.getUuid()));
|
||||
|
||||
SampleJoinEntity sampleAnswerEntity2 = new SampleJoinEntity();
|
||||
sampleAnswerEntity1.setUuid("a2");
|
||||
sampleAnswerEntity1.setText("This is an answer");
|
||||
sampleAnswerEntity1.setMyJoinField(new JoinField<>("answer", sampleQuestionEntity1.getUuid()));
|
||||
|
||||
IndexOperations indexOps = operations.indexOps(SampleJoinEntity.class);
|
||||
operations.save(Arrays.asList(sampleQuestionEntity1, sampleAnswerEntity1, sampleAnswerEntity2));
|
||||
indexOps.refresh();
|
||||
|
||||
// when
|
||||
Query query = new NativeSearchQueryBuilder().withQuery(
|
||||
JoinQueryBuilders.hasChildQuery("answer", matchAllQuery(), org.apache.lucene.search.join.ScoreMode.Avg)
|
||||
.innerHit(new InnerHitBuilder("innerHits").setSize(0)))
|
||||
.build();
|
||||
|
||||
SearchHits<SampleJoinEntity> searchHits = operations.search(query, SampleJoinEntity.class);
|
||||
|
||||
// then
|
||||
assertThat(searchHits).isNotNull();
|
||||
assertThat(searchHits.getTotalHits()).isEqualTo(1);
|
||||
assertThat(searchHits.getSearchHits()).hasSize(1);
|
||||
assertThat(searchHits.getSearchHit(0).getInnerHits().size()).isEqualTo(1);
|
||||
assertThat(searchHits.getSearchHit(0).getInnerHits("innerHits").getTotalHits()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // DATAES-541
|
||||
public void shouldRemoveAlias() {
|
||||
|
||||
|
||||
+211
-70
@@ -308,8 +308,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "ignore-above-index")
|
||||
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() {
|
||||
@@ -334,13 +336,17 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@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")
|
||||
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;
|
||||
@@ -349,42 +355,57 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "fieldname-index")
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
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"),
|
||||
@@ -396,11 +417,15 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-book-mapping-builder")
|
||||
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<Integer, Collection<String>> 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<Integer, Collection<String>> 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;
|
||||
|
||||
@@ -452,9 +477,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-simple-recursive-mapping-builder")
|
||||
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() {
|
||||
@@ -477,10 +503,14 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-copy-to-mapping-builder")
|
||||
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() {
|
||||
@@ -522,9 +552,12 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-normalizer-mapping-builder")
|
||||
@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
|
||||
@@ -582,7 +615,8 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-sample-inherited-mapping-builder")
|
||||
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() {
|
||||
@@ -627,9 +661,11 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-stock-mapping-builder")
|
||||
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() {
|
||||
@@ -660,8 +696,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
|
||||
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() {
|
||||
@@ -684,19 +722,25 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-geo-mapping-builder")
|
||||
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
|
||||
@@ -792,7 +836,8 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-user-mapping-builder")
|
||||
static class User {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
|
||||
@Field(type = FieldType.Nested, ignoreFields = { "users" }) private Set<Group> groups = new HashSet<>();
|
||||
}
|
||||
@@ -800,7 +845,8 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-group-mapping-builder")
|
||||
static class Group {
|
||||
|
||||
@Nullable @Id String id;
|
||||
@Nullable
|
||||
@Id String id;
|
||||
|
||||
@Field(type = FieldType.Nested, ignoreFields = { "groups" }) private Set<User> users = new HashSet<>();
|
||||
}
|
||||
@@ -819,8 +865,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "completion")
|
||||
static class CompletionDocument {
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
@Nullable
|
||||
@CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO,
|
||||
path = "proppath") }) private Completion suggest;
|
||||
|
||||
@Nullable
|
||||
@@ -844,7 +892,8 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder")
|
||||
static class EntityWithSeqNoPrimaryTerm {
|
||||
@Nullable @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
@Nullable
|
||||
@Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
||||
|
||||
@Nullable
|
||||
public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
|
||||
@@ -857,10 +906,14 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
|
||||
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<String, Integer> 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<String, Integer> topics;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
@@ -901,16 +954,23 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "termvectors-test")
|
||||
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
|
||||
@@ -988,8 +1048,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "wildcard-test")
|
||||
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() {
|
||||
@@ -1013,8 +1075,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "disabled-entity-mapping")
|
||||
@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() {
|
||||
@@ -1037,9 +1101,13 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@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() {
|
||||
@@ -1071,8 +1139,10 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "densevector-test")
|
||||
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() {
|
||||
@@ -1097,11 +1167,15 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
@DynamicMapping(DynamicMappingValue.False)
|
||||
static class DynamicMappingEntity {
|
||||
|
||||
@Nullable @DynamicMapping(DynamicMappingValue.Strict) @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @DynamicMapping(DynamicMappingValue.False) @Field(
|
||||
type = FieldType.Object) private Map<String, Object> objectMap;
|
||||
@Nullable @DynamicMapping(DynamicMappingValue.False) @Field(
|
||||
type = FieldType.Nested) private List<Map<String, Object>> nestedObjectMap;
|
||||
@Nullable
|
||||
@DynamicMapping(DynamicMappingValue.Strict)
|
||||
@Field(type = FieldType.Object) private Author author;
|
||||
@Nullable
|
||||
@DynamicMapping(DynamicMappingValue.False)
|
||||
@Field(type = FieldType.Object) private Map<String, Object> objectMap;
|
||||
@Nullable
|
||||
@DynamicMapping(DynamicMappingValue.False)
|
||||
@Field(type = FieldType.Nested) private List<Map<String, Object>> nestedObjectMap;
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
@@ -1113,4 +1187,71 @@ public class MappingBuilderIntegrationTests extends MappingContextBaseTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Document(indexName = "allTypes")
|
||||
private static class EntityWithAllTypes {
|
||||
@Nullable
|
||||
@Field(type = FieldType.Auto) String autoField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Text) String textField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Keyword) String keywordField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Long) String longField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Integer) String integerField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Short) String shortField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Byte) String byteField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Double) String doubleField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Float) String floatField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Half_Float) String halfFloatField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Scaled_Float) String scaledFloatField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Date) String dateField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Date_Nanos) String dateNanosField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Boolean) String booleanField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Binary) String binaryField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Integer_Range) String integerRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Float_Range) String floatRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Long_Range) String longRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Double_Range) String doubleRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Date_Range) String dateRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Ip_Range) String ipRangeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Object) String objectField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Nested) String nestedField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Ip) String ipField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.TokenCount, analyzer = "standard") String tokenCountField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Percolator) String percolatorField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Flattened) String flattenedField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Search_As_You_Type) String searchAsYouTypeField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Rank_Feature) String rankFeatureField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Rank_Features) String rankFeaturesField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Wildcard) String wildcardField;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Dense_Vector, dims = 1) String denseVectorField;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user