From a203f9b87adbcc06561769c390dd12645170b5ce Mon Sep 17 00:00:00 2001 From: jpvel Date: Fri, 15 Nov 2019 02:11:57 +0530 Subject: [PATCH 01/14] Migrated the code to support latest e.s - 7.3.1 --- pom.xml | 17 +---------------- .../elasticsearch/mapping/ObjectMapping.java | 5 ++++- .../mapping/entities/model/BookEntity.java | 7 ++++--- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index ee07e51..0763c7c 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ github - 5.6.16 + 7.3.1 6.14.3 2.25.1 0.8.3 @@ -270,21 +270,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - ${maven-gpg-plugin.version} - - - sign-artifacts - verify - - sign - - - - - org.sonatype.plugins nexus-staging-maven-plugin diff --git a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java index 3449104..65f0f69 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java @@ -1,5 +1,6 @@ package org.frekele.elasticsearch.mapping; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -25,7 +26,9 @@ public XContentBuilder getContent() throws IOException { } public String getContentAsString() throws IOException { - return this.getContent().string(); + //return this.getContent(). + String json = Strings.toString(mapping); + return json; } } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java index ab18e32..3b67411 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java @@ -1,5 +1,7 @@ package org.frekele.elasticsearch.mapping.entities.model; +import java.time.OffsetDateTime; + import org.frekele.elasticsearch.mapping.annotations.ElasticBinaryField; import org.frekele.elasticsearch.mapping.annotations.ElasticBooleanField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateField; @@ -7,8 +9,7 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; import org.frekele.elasticsearch.mapping.annotations.ElasticObjectField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; - -import java.time.OffsetDateTime; +import org.frekele.elasticsearch.mapping.annotations.values.BoolValue; @ElasticDocument("book") public class BookEntity { @@ -32,7 +33,7 @@ public class BookEntity { @ElasticBinaryField private String imageBlob; - @ElasticObjectField + @ElasticObjectField(enabledJson = @BoolValue(false)) private AuthorEntity author; public BookEntity() { From d146efa0e0710b4feec517b9e7b43f7b42bb236b Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 11:37:55 +0100 Subject: [PATCH 02/14] upgrade to elastic 7.x mappings only have one type remove _parent --- README.md | 2 +- pom.xml | 8 +- .../elasticsearch/mapping/MappingBuilder.java | 4 +- .../mapping/MappingBuilderImpl.java | 79 +++++++------------ .../mapping/annotations/ElasticDocument.java | 2 - .../elasticsearch/mapping/BookTest.java | 5 +- .../elasticsearch/mapping/EmployeeTest.java | 8 +- .../mapping/MappingBuilderTest.java | 31 ++------ .../elasticsearch/mapping/ProductTest.java | 4 +- .../generic/ParentDocumentEntity.java | 27 ------- .../entities/model/EmployeeEntity.java | 2 +- 11 files changed, 54 insertions(+), 118 deletions(-) delete mode 100644 src/test/java/org/frekele/elasticsearch/mapping/entities/generic/ParentDocumentEntity.java diff --git a/README.md b/README.md index ea00433..284663c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ | Elasticsearch Mapping Builder | Elasticsearch | | ------------------------------| ---------------------- | -| Version: 1.0.7 | Version: 5.x.x | +| Version: 1.0.7 | Version: 7.x.x | #### Maven dependency: diff --git a/pom.xml b/pom.xml index 0763c7c..2c0e607 100644 --- a/pom.xml +++ b/pom.xml @@ -87,10 +87,10 @@ github - 7.3.1 - 6.14.3 - 2.25.1 - 0.8.3 + 7.6.1 + 7.1.1 + 3.3.3 + 0.8.5 3.8.0 3.1.1 diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilder.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilder.java index 7f367ac..01cdbc2 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilder.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilder.java @@ -9,7 +9,7 @@ */ public interface MappingBuilder extends Serializable { - public ObjectMapping build(Class... documentClass); + public ObjectMapping build(Class documentClass); - public ObjectMapping build(boolean pretty, Class... documentClass); + public ObjectMapping build(boolean pretty, Class documentClass); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java index f75ac9e..657bd56 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java @@ -52,7 +52,6 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -66,7 +65,7 @@ public class MappingBuilderImpl implements MappingBuilder { private int MAX_RECURSIVE_LEVEL = 50; - private List docsClass; + private Class docsClass; private XContentBuilder mapping; @@ -74,16 +73,16 @@ public MappingBuilderImpl() { } @Override - public ObjectMapping build(Class... documentClass) { + public ObjectMapping build(Class documentClass) { return this.build(false, documentClass); } @Override - public ObjectMapping build(boolean pretty, Class... documentClass) { - if (documentClass == null || documentClass.length == 0) { + public ObjectMapping build(boolean pretty, Class documentClass) { + if (documentClass == null) { throw new MappingBuilderException("A Document Class is required."); } else { - this.docsClass = Arrays.asList(documentClass); + this.docsClass = documentClass; } this.validateElasticDocument(); try { @@ -94,7 +93,7 @@ public ObjectMapping build(boolean pretty, Class... documentClass) { } } - public List getDocsClass() { + public Class getDocClass() { return docsClass; } @@ -111,10 +110,8 @@ public static boolean isElasticDocument(Class documentClass) { } public void validateElasticDocument() { - for (Class clazz : this.getDocsClass()) { - if (!isElasticDocument(clazz)) { - throw new InvalidDocumentClassException("Document Class[" + clazz.getCanonicalName() + "] Invalid. @ElasticDocument must be present."); - } + if (!isElasticDocument(this.getDocClass())) { + throw new InvalidDocumentClassException("Document Class[" + this.getDocClass().getCanonicalName() + "] Invalid. @ElasticDocument must be present."); } } @@ -294,9 +291,6 @@ public void closeSuffixName(boolean subField) throws IOException { } //Direct set. - public void nested(boolean nested) throws IOException { - this.getMapping().field("nested", nested); - } public void dynamic(BoolValue dynamic) throws IOException { this.addField("dynamic", dynamic); @@ -795,7 +789,7 @@ public void recursiveFields(Field[] fields, int level) throws IOException { //Nested. else if (field.isAnnotationPresent(ElasticNestedField.class)) { ElasticNestedField elasticDocument = field.getAnnotation(ElasticNestedField.class); - this.nested(true); + this.type(FieldType.NESTED); this.dynamic(elasticDocument.dynamic()); this.includeInAll(elasticDocument.includeInAll()); this.recursiveFields(this.getInnerFields(field), level); @@ -803,7 +797,7 @@ else if (field.isAnnotationPresent(ElasticNestedField.class)) { //Fields. else { List annotationList = getElasticFieldAnnotations(field); - if (!annotationList.isEmpty()) { + if (annotationList != null && !annotationList.isEmpty()) { //Get main Field (The First) Annotation mainAnnotation = annotationList.get(0); this.processElasticAnnotationField(mainAnnotation, false); @@ -839,46 +833,33 @@ public XContentBuilder innerBuild(boolean pretty) throws IOException { this.getMapping().startObject(); this.getMapping().startObject("mappings"); - for (Class clazz : this.getDocsClass()) { - ElasticDocument elasticDocument = (ElasticDocument) clazz.getAnnotation(ElasticDocument.class); - this.getMapping().startObject(elasticDocument.value()); + ElasticDocument elasticDocument = (ElasticDocument) this.getDocClass().getAnnotation(ElasticDocument.class); - //_parent - if (isNotEmpty(elasticDocument.parent())) { - this.getMapping().startObject("_parent"); - this.getMapping().field("type", elasticDocument.parent()); - this.eagerGlobalOrdinals(elasticDocument.eagerGlobalOrdinalsParent()); - this.getMapping().endObject(); + //_all + if (isValueEnabled(elasticDocument.enabledAll()) || isValueEnabled(elasticDocument.storeAll())) { + this.getMapping().startObject("_all"); + if (isValueEnabled(elasticDocument.enabledAll())) { + this.getMapping().field("enabled", elasticDocument.enabledAll().value()); } - - //_all - if (isValueEnabled(elasticDocument.enabledAll()) || isValueEnabled(elasticDocument.storeAll())) { - this.getMapping().startObject("_all"); - if (isValueEnabled(elasticDocument.enabledAll())) { - this.getMapping().field("enabled", elasticDocument.enabledAll().value()); - } - if (isValueEnabled(elasticDocument.storeAll())) { - this.getMapping().field("store", elasticDocument.storeAll().value()); - } - this.getMapping().endObject(); + if (isValueEnabled(elasticDocument.storeAll())) { + this.getMapping().field("store", elasticDocument.storeAll().value()); } + this.getMapping().endObject(); + } - //_routing - if (isValueEnabled(elasticDocument.requiredRouting())) { - this.getMapping().startObject("_routing"); - this.getMapping().field("required", elasticDocument.requiredRouting().value()); - this.getMapping().endObject(); - } + //_routing + if (isValueEnabled(elasticDocument.requiredRouting())) { + this.getMapping().startObject("_routing"); + this.getMapping().field("required", elasticDocument.requiredRouting().value()); + this.getMapping().endObject(); + } - this.dynamic(elasticDocument.dynamic()); - this.includeInAll(elasticDocument.includeInAll()); + this.dynamic(elasticDocument.dynamic()); + this.includeInAll(elasticDocument.includeInAll()); - Field[] fields = clazz.getDeclaredFields(); - this.recursiveFields(fields, 0); + Field[] fields = this.getDocClass().getDeclaredFields(); + this.recursiveFields(fields, 0); - //ElasticDocument - this.getMapping().endObject(); - } //mappings this.getMapping().endObject(); //END diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java index 99aead1..43e3e6f 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java @@ -23,8 +23,6 @@ BoolValue includeInAll() default @BoolValue(ignore = true); - String parent() default ""; - //add eager_global_ordinals into _parent BoolValue eagerGlobalOrdinalsParent() default @BoolValue(ignore = true); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/BookTest.java b/src/test/java/org/frekele/elasticsearch/mapping/BookTest.java index df97098..f91b280 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/BookTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/BookTest.java @@ -1,5 +1,6 @@ package org.frekele.elasticsearch.mapping; +import org.frekele.elasticsearch.mapping.entities.model.AuthorEntity; import org.frekele.elasticsearch.mapping.entities.model.BookEntity; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -23,10 +24,10 @@ public void tearDown() throws Exception { @Test public void buildBookTest() throws Exception { - String expected = "{\"mappings\":{\"book\":{\"properties\":{\"isbn\":{\"type\":\"keyword\"},\"name\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"description\":{\"type\":\"text\"},\"releaseDate\":{\"type\":\"date\"},\"active\":{\"type\":\"boolean\"},\"imageBlob\":{\"type\":\"binary\"},\"author\":{\"properties\":{\"id\":{\"type\":\"long\"},\"name\":{\"type\":\"text\"},\"artisticName\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"address\":{\"nested\":true,\"properties\":{\"postalCode\":{\"type\":\"keyword\"},\"street\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}},\"number\":{\"type\":\"long\"}}}}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"isbn\":{\"type\":\"keyword\"},\"name\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"description\":{\"type\":\"text\"},\"releaseDate\":{\"type\":\"date\"},\"active\":{\"type\":\"boolean\"},\"imageBlob\":{\"type\":\"binary\"},\"author\":{\"enabled\":false,\"properties\":{\"id\":{\"type\":\"long\"},\"name\":{\"type\":\"text\"},\"artisticName\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"address\":{\"type\":\"nested\",\"properties\":{\"postalCode\":{\"type\":\"keyword\"},\"street\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}},\"number\":{\"type\":\"long\"}}}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(BookEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); + assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); //System.out.println(result.sourceAsString()); System.out.println(mappingBuilder.build(true, BookEntity.class).getContentAsString()); } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java b/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java index e1ed764..cccbab1 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java @@ -24,11 +24,11 @@ public void tearDown() throws Exception { @Test public void buildEmployeeTest() throws Exception { - String expected = "{\"mappings\":{\"person\":{\"properties\":{\"id\":{\"type\":\"long\"},\"name\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"fullName\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\"fistName\":{\"type\":\"text\",\"copy_to\":[\"name\",\"fullName\"]},\"lastName\":{\"type\":\"text\",\"copy_to\":\"fullName\"},\"multipleAddress\":{\"properties\":{\"postalCode\":{\"type\":\"keyword\"},\"street\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}},\"number\":{\"type\":\"long\"}}}}},\"employee\":{\"_parent\":{\"type\":\"person\"},\"properties\":{\"id\":{\"type\":\"long\"},\"documentNumber\":{\"type\":\"keyword\"},\"registerNumber\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}}}}"; + String expected = "{\"mappings\":{\"_parent\":{\"type\":\"person\"},\"properties\":{\"id\":{\"type\":\"long\"},\"documentNumber\":{\"type\":\"keyword\"},\"registerNumber\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}}}"; MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); - ObjectMapping result = mappingBuilder.build(PersonEntity.class, EmployeeEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); + ObjectMapping result = mappingBuilder.build(EmployeeEntity.class); + assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); //System.out.println(result.sourceAsString()); - System.out.println(mappingBuilder.build(true, PersonEntity.class, EmployeeEntity.class).getContentAsString()); + System.out.println(mappingBuilder.build(true, EmployeeEntity.class).getContentAsString()); } } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index 9b65c68..591c365 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -1,11 +1,6 @@ package org.frekele.elasticsearch.mapping; -import org.frekele.elasticsearch.mapping.entities.generic.FullDocumentEntity; -import org.frekele.elasticsearch.mapping.entities.generic.FullDocumentTwoEntity; -import org.frekele.elasticsearch.mapping.entities.generic.IncorrectCustomJsonFieldEntity; -import org.frekele.elasticsearch.mapping.entities.generic.NoDocumentEntity; -import org.frekele.elasticsearch.mapping.entities.generic.ParentDocumentEntity; -import org.frekele.elasticsearch.mapping.entities.generic.RecursiveErrorDocumentEntity; +import org.frekele.elasticsearch.mapping.entities.generic.*; import org.frekele.elasticsearch.mapping.exceptions.InvalidCustomJsonException; import org.frekele.elasticsearch.mapping.exceptions.InvalidDocumentClassException; import org.frekele.elasticsearch.mapping.exceptions.MappingBuilderException; @@ -14,7 +9,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static org.testng.Assert.assertEquals; /** * @author frekele - Leandro Kersting de Freitas @@ -56,7 +51,7 @@ public void validateWithErrorTest() throws Exception { @Test(expectedExceptions = MappingBuilderException.class) public void validateWithErrorTest2() throws Exception { MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); - mappingBuilder.build(); + mappingBuilder.build(null); mappingBuilder.validateElasticDocument(); } @@ -74,34 +69,22 @@ public void buildWithRecursiveErrorTest() throws Exception { @Test public void buildTest() throws Exception { - String expected = "{\"mappings\":{\"full\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"},\"nestedValue\":{\"nested\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}}" + - ",\"multiFieldValue\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"},\"nestedValue\":{\"type\":\"nested\",\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); + assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); //System.out.println(result.sourceAsString()); System.out.println(mappingBuilder.build(true, FullDocumentEntity.class).getContentAsString()); } @Test public void buildTest2() throws Exception { - String expected = "{\"mappings\":{\"full_two\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"include_in_all\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"nested\":true,\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}}" + - ",\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"include_in_all\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentTwoEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); + assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); //System.out.println(result.sourceAsString()); System.out.println(mappingBuilder.build(true, FullDocumentTwoEntity.class).getContentAsString()); } - @Test - public void buildTest3() throws Exception { - String expected = "{\"mappings\":{\"my_doc_type\":{\"_parent\":{\"type\":\"my_parent_doc_type\",\"eager_global_ordinals\":true},\"_all\":{\"enabled\":true,\"store\":true},\"_routing\":{\"required\":true},\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"id\":{\"type\":\"long\"}}}}}"; - MappingBuilder mappingBuilder = new MappingBuilderImpl(); - ObjectMapping result = mappingBuilder.build(ParentDocumentEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); - //System.out.println(result.sourceAsString()); - System.out.println(mappingBuilder.build(true, ParentDocumentEntity.class).getContentAsString()); - } - } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/ProductTest.java b/src/test/java/org/frekele/elasticsearch/mapping/ProductTest.java index 555a31b..02e729b 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/ProductTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/ProductTest.java @@ -23,10 +23,10 @@ public void tearDown() throws Exception { @Test public void buildProductTest() throws Exception { - String expected = "{\"mappings\":{\"product\":{\"properties\":{\"id\":{\"type\":\"long\"},\"size\":{\"type\":\"integer\"},\"height\":{\"type\":\"float\"},\"width\":{\"type\":\"float\"},\"depth\":{\"type\":\"float\"},\"price\":{\"type\":\"double\"}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"id\":{\"type\":\"long\"},\"size\":{\"type\":\"integer\"},\"height\":{\"type\":\"float\"},\"width\":{\"type\":\"float\"},\"depth\":{\"type\":\"float\"},\"price\":{\"type\":\"double\"}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(ProductEntity.class); - assertEquals(result.getContentAsString().replaceAll("\\r|\\n", ""), expected); + assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); //System.out.println(result.sourceAsString()); System.out.println(mappingBuilder.build(true, ProductEntity.class).getContentAsString()); } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/ParentDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/ParentDocumentEntity.java deleted file mode 100644 index 0f5f303..0000000 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/ParentDocumentEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.frekele.elasticsearch.mapping.entities.generic; - -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; -import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; -import org.frekele.elasticsearch.mapping.annotations.values.BoolValue; - -@ElasticDocument( - value = "my_doc_type", - dynamic = @BoolValue(true), - includeInAll = @BoolValue(true), - parent = "my_parent_doc_type", - //add eager_global_ordinals into _parent - eagerGlobalOrdinalsParent = @BoolValue(true), - enabledAll = @BoolValue(true), - //add store into _all - storeAll = @BoolValue(true), - //add required into _routing - requiredRouting = @BoolValue(true) -) -public class ParentDocumentEntity { - - @ElasticLongField - private Long id; - - public ParentDocumentEntity() { - } -} diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java index d35528b..76fed08 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java @@ -5,7 +5,7 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; -@ElasticDocument(value = "employee", parent = "person") +@ElasticDocument(value = "employee") public class EmployeeEntity { @ElasticLongField From cd6dd6ab8b54cb9d9c28bbebfbc96a479fbc9933 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 11:38:48 +0100 Subject: [PATCH 03/14] fixup! upgrade to elastic 7.x mappings only have one type remove _parent --- .../java/org/frekele/elasticsearch/mapping/EmployeeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java b/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java index cccbab1..ae3dbc8 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/EmployeeTest.java @@ -24,7 +24,7 @@ public void tearDown() throws Exception { @Test public void buildEmployeeTest() throws Exception { - String expected = "{\"mappings\":{\"_parent\":{\"type\":\"person\"},\"properties\":{\"id\":{\"type\":\"long\"},\"documentNumber\":{\"type\":\"keyword\"},\"registerNumber\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"id\":{\"type\":\"long\"},\"documentNumber\":{\"type\":\"keyword\"},\"registerNumber\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}}}"; MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(EmployeeEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); From bd3b68d0263eb43e8145300b095fa47b4837f3ff Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 11:47:57 +0100 Subject: [PATCH 04/14] add default analyser on ElasticTokenCountField scalingFactor is required on ElasticScaledFloatField --- .../mapping/annotations/ElasticScaledFloatField.java | 2 +- .../mapping/annotations/ElasticTokenCountField.java | 2 +- .../org/frekele/elasticsearch/mapping/MappingBuilderTest.java | 4 ++-- .../mapping/entities/generic/FullDocumentEntity.java | 3 ++- .../mapping/entities/generic/InnerDocumentEntity.java | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java index 0759b83..3ffcd2b 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java @@ -41,6 +41,6 @@ BoolValue store() default @BoolValue(ignore = true); - IntValue scalingFactor() default @IntValue(ignore = true); + IntValue scalingFactor(); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java index cd7272c..255570e 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java @@ -23,7 +23,7 @@ String suffixName() default "tokenCount"; - String analyzer() default ""; + String analyzer() default "standard"; BoolValue enablePositionIncrements() default @BoolValue(ignore = true); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index 591c365..e6fa554 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -69,7 +69,7 @@ public void buildWithRecursiveErrorTest() throws Exception { @Test public void buildTest() throws Exception { - String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"},\"nestedValue\":{\"type\":\"nested\",\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"},\"nestedValue\":{\"type\":\"nested\",\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"},\"completion\":{\"type\":\"completion\"}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); @@ -79,7 +79,7 @@ public void buildTest() throws Exception { @Test public void buildTest2() throws Exception { - String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"include_in_all\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\"},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"include_in_all\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentTwoEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java index 557fa6b..2fc18e5 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java @@ -29,6 +29,7 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticShortField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; import org.frekele.elasticsearch.mapping.annotations.ElasticTokenCountField; +import org.frekele.elasticsearch.mapping.annotations.values.IntValue; import java.util.Date; @@ -98,7 +99,7 @@ public class FullDocumentEntity { @ElasticPercolatorField private String percolatorValue; - @ElasticScaledFloatField + @ElasticScaledFloatField(scalingFactor = @IntValue(100)) private Float scaledFloatValue; @ElasticShortField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/InnerDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/InnerDocumentEntity.java index 832ad80..23ae7c3 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/InnerDocumentEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/InnerDocumentEntity.java @@ -25,6 +25,7 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticShortField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; import org.frekele.elasticsearch.mapping.annotations.ElasticTokenCountField; +import org.frekele.elasticsearch.mapping.annotations.values.IntValue; import java.util.Date; @@ -93,7 +94,7 @@ public class InnerDocumentEntity { @ElasticPercolatorField private String percolatorValue; - @ElasticScaledFloatField + @ElasticScaledFloatField(scalingFactor = @IntValue(50)) private Float scaledFloatValue; @ElasticShortField From 568020b023d5fe869445523c9359c35766051506 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 11:57:57 +0100 Subject: [PATCH 05/14] remove _all --- README.md | 3 - .../mapping/MappingBuilderImpl.java | 56 +++++-------------- .../mapping/annotations/ElasticByteField.java | 2 - .../mapping/annotations/ElasticDateField.java | 2 - .../annotations/ElasticDateRangeField.java | 2 - .../mapping/annotations/ElasticDocument.java | 7 --- .../annotations/ElasticDoubleField.java | 2 - .../annotations/ElasticDoubleRangeField.java | 2 - .../annotations/ElasticFloatField.java | 2 - .../annotations/ElasticFloatRangeField.java | 2 - .../annotations/ElasticHalfFloatField.java | 2 - .../annotations/ElasticIntegerField.java | 2 - .../annotations/ElasticIntegerRangeField.java | 2 - .../mapping/annotations/ElasticIpField.java | 2 - .../annotations/ElasticIpRangeField.java | 2 - .../annotations/ElasticKeywordField.java | 2 - .../mapping/annotations/ElasticLongField.java | 2 - .../annotations/ElasticLongRangeField.java | 2 - .../annotations/ElasticNestedField.java | 2 - .../annotations/ElasticObjectField.java | 2 - .../annotations/ElasticScaledFloatField.java | 2 - .../annotations/ElasticShortField.java | 2 - .../mapping/annotations/ElasticTextField.java | 2 - .../annotations/ElasticTokenCountField.java | 2 - .../mapping/values/DateFieldValue.java | 9 +-- .../mapping/values/NumericFieldValue.java | 9 +-- .../mapping/values/RangeFieldValue.java | 9 +-- .../mapping/MappingBuilderTest.java | 2 +- 28 files changed, 19 insertions(+), 118 deletions(-) diff --git a/README.md b/README.md index 284663c..7c4e07e 100644 --- a/README.md +++ b/README.md @@ -186,9 +186,6 @@ public class EmployeeEntity { parent = "my_parent_doc_type", //add eager_global_ordinals into _parent eagerGlobalOrdinalsParent = @BoolValue(true), - enabledAll = @BoolValue(true), - //add store into _all - storeAll = @BoolValue(true), //add required into _routing requiredRouting = @BoolValue(true) ) diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java index 657bd56..e914780 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java @@ -339,10 +339,6 @@ public void fielddataFrequencyFilter(FielddataFrequencyFilterValue fielddataFreq } } - public void includeInAll(BoolValue includeInAll) throws IOException { - this.addField("include_in_all", includeInAll); - } - public void index(BoolValue index) throws IOException { this.addField("index", index); } @@ -479,7 +475,6 @@ public void processElasticField(ElasticTextField elasticField, boolean subField) this.eagerGlobalOrdinals(elasticField.eagerGlobalOrdinals()); this.fielddata(elasticField.fielddata()); this.fielddataFrequencyFilter(elasticField.fielddataFrequencyFilter()); - this.includeInAll(elasticField.includeInAll()); this.index(elasticField.index()); this.indexOptions(elasticField.indexOptions()); this.norms(elasticField.norms()); @@ -501,7 +496,6 @@ public void processElasticField(ElasticKeywordField elasticField, boolean subFie this.docValues(elasticField.docValues()); this.eagerGlobalOrdinals(elasticField.eagerGlobalOrdinals()); this.ignoreAbove(elasticField.ignoreAbove()); - this.includeInAll(elasticField.includeInAll()); this.index(elasticField.index()); this.indexOptions(elasticField.indexOptions()); this.norms(elasticField.norms()); @@ -519,7 +513,6 @@ public void processElasticField(NumericFieldValue vo, boolean subField) throws I this.boost(vo.getBoost()); this.docValues(vo.getDocValues()); this.ignoreMalformed(vo.getIgnoreMalformed()); - this.includeInAll(vo.getIncludeInAll()); this.index(vo.getIndex()); this.nullValue(vo.getNullValue()); this.store(vo.getStore()); @@ -529,63 +522,63 @@ public void processElasticField(NumericFieldValue vo, boolean subField) throws I public void processElasticField(ElasticLongField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticIntegerField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticShortField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticByteField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticDoubleField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticHalfFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticScaledFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store(), elasticField.scalingFactor()); this.processElasticField(vo, subField); } public void processElasticField(ElasticDateField elasticField, boolean subField) throws IOException { DateFieldValue vo = new DateFieldValue(elasticField.type, elasticField.suffixName(), elasticField.boost(), - elasticField.docValues(), elasticField.format(), elasticField.locale(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.docValues(), elasticField.format(), elasticField.locale(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store()); this.processElasticField(vo, subField); } @@ -614,7 +607,6 @@ public void processElasticField(RangeFieldValue vo, boolean subField) throws IOE this.type(vo.getType()); this.coerce(vo.getCoerce()); this.boost(vo.getBoost()); - this.includeInAll(vo.getIncludeInAll()); this.index(vo.getIndex()); this.store(vo.getStore()); this.closeSuffixName(subField); @@ -622,31 +614,31 @@ public void processElasticField(RangeFieldValue vo, boolean subField) throws IOE public void processElasticField(ElasticIntegerRangeField elasticField, boolean subField) throws IOException { RangeFieldValue vo = new RangeFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.includeInAll(), elasticField.index(), elasticField.store()); + elasticField.boost(), elasticField.index(), elasticField.store()); this.processElasticField(vo, subField); } public void processElasticField(ElasticFloatRangeField elasticField, boolean subField) throws IOException { RangeFieldValue vo = new RangeFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.includeInAll(), elasticField.index(), elasticField.store()); + elasticField.boost(), elasticField.index(), elasticField.store()); this.processElasticField(vo, subField); } public void processElasticField(ElasticLongRangeField elasticField, boolean subField) throws IOException { RangeFieldValue vo = new RangeFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.includeInAll(), elasticField.index(), elasticField.store()); + elasticField.boost(), elasticField.index(), elasticField.store()); this.processElasticField(vo, subField); } public void processElasticField(ElasticDoubleRangeField elasticField, boolean subField) throws IOException { RangeFieldValue vo = new RangeFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.includeInAll(), elasticField.index(), elasticField.store()); + elasticField.boost(), elasticField.index(), elasticField.store()); this.processElasticField(vo, subField); } public void processElasticField(ElasticIpRangeField elasticField, boolean subField) throws IOException { RangeFieldValue vo = new RangeFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), - elasticField.boost(), elasticField.includeInAll(), elasticField.index(), elasticField.store()); + elasticField.boost(), elasticField.index(), elasticField.store()); this.processElasticField(vo, subField); } @@ -658,7 +650,6 @@ public void processElasticField(DateFieldValue vo, boolean subField) throws IOEx this.format(vo.getFormat()); this.locale(vo.getLocale()); this.ignoreMalformed(vo.getIgnoreMalformed()); - this.includeInAll(vo.getIncludeInAll()); this.index(vo.getIndex()); this.nullValue(vo.getNullValue()); this.store(vo.getStore()); @@ -667,7 +658,7 @@ public void processElasticField(DateFieldValue vo, boolean subField) throws IOEx public void processElasticField(ElasticDateRangeField elasticField, boolean subField) throws IOException { DateFieldValue vo = new DateFieldValue(elasticField.type, elasticField.suffixName(), elasticField.boost(), - elasticField.docValues(), elasticField.format(), elasticField.locale(), elasticField.ignoreMalformed(), elasticField.includeInAll(), + elasticField.docValues(), elasticField.format(), elasticField.locale(), elasticField.ignoreMalformed(), elasticField.index(), elasticField.nullValue(), elasticField.store()); this.processElasticField(vo, subField); } @@ -697,7 +688,6 @@ public void processElasticField(ElasticIpField elasticField, boolean subField) t this.type(elasticField.type); this.boost(elasticField.boost()); this.docValues(elasticField.docValues()); - this.includeInAll(elasticField.includeInAll()); this.index(elasticField.index()); this.nullValue(elasticField.nullValue()); this.store(elasticField.store()); @@ -723,7 +713,6 @@ public void processElasticField(ElasticTokenCountField elasticField, boolean sub this.boost(elasticField.boost()); this.docValues(elasticField.docValues()); this.index(elasticField.index()); - this.includeInAll(elasticField.includeInAll()); this.nullValue(elasticField.nullValue()); this.store(elasticField.store()); this.closeSuffixName(subField); @@ -783,7 +772,6 @@ public void recursiveFields(Field[] fields, int level) throws IOException { ElasticObjectField elasticDocument = field.getAnnotation(ElasticObjectField.class); this.dynamic(elasticDocument.dynamic()); this.enabledJson(elasticDocument.enabledJson()); - this.includeInAll(elasticDocument.includeInAll()); this.recursiveFields(this.getInnerFields(field), level); } //Nested. @@ -791,7 +779,6 @@ else if (field.isAnnotationPresent(ElasticNestedField.class)) { ElasticNestedField elasticDocument = field.getAnnotation(ElasticNestedField.class); this.type(FieldType.NESTED); this.dynamic(elasticDocument.dynamic()); - this.includeInAll(elasticDocument.includeInAll()); this.recursiveFields(this.getInnerFields(field), level); } //Fields. @@ -835,18 +822,6 @@ public XContentBuilder innerBuild(boolean pretty) throws IOException { ElasticDocument elasticDocument = (ElasticDocument) this.getDocClass().getAnnotation(ElasticDocument.class); - //_all - if (isValueEnabled(elasticDocument.enabledAll()) || isValueEnabled(elasticDocument.storeAll())) { - this.getMapping().startObject("_all"); - if (isValueEnabled(elasticDocument.enabledAll())) { - this.getMapping().field("enabled", elasticDocument.enabledAll().value()); - } - if (isValueEnabled(elasticDocument.storeAll())) { - this.getMapping().field("store", elasticDocument.storeAll().value()); - } - this.getMapping().endObject(); - } - //_routing if (isValueEnabled(elasticDocument.requiredRouting())) { this.getMapping().startObject("_routing"); @@ -855,7 +830,6 @@ public XContentBuilder innerBuild(boolean pretty) throws IOException { } this.dynamic(elasticDocument.dynamic()); - this.includeInAll(elasticDocument.includeInAll()); Field[] fields = this.getDocClass().getDeclaredFields(); this.recursiveFields(fields, 0); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java index 6fded6f..595f1fb 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateField.java index a54afbd..bf6b0e2 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateField.java @@ -37,8 +37,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java index a87ddc7..0a51ab8 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java @@ -34,8 +34,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java index 43e3e6f..9877051 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java @@ -21,16 +21,9 @@ BoolValue dynamic() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - //add eager_global_ordinals into _parent BoolValue eagerGlobalOrdinalsParent() default @BoolValue(ignore = true); - BoolValue enabledAll() default @BoolValue(ignore = true); - - //add store into _all - BoolValue storeAll() default @BoolValue(ignore = true); - //add required into _routing BoolValue requiredRouting() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java index 90aa087..23419fc 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleRangeField.java index 1981957..82dd4fe 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleRangeField.java @@ -28,8 +28,6 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java index 17d5d1b..6dad1b9 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatRangeField.java index 933166a..e04ec53 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatRangeField.java @@ -28,8 +28,6 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java index 63e790a..ddb3cdd 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java index 8b8ef36..5498527 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerRangeField.java index b951914..485d1b4 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerRangeField.java @@ -28,8 +28,6 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpField.java index df203a8..e33e439 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpField.java @@ -28,8 +28,6 @@ BoolValue docValues() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpRangeField.java index 9b9444a..e349c8b 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIpRangeField.java @@ -28,8 +28,6 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticKeywordField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticKeywordField.java index 4cc8509..2852024 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticKeywordField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticKeywordField.java @@ -35,8 +35,6 @@ IntValue ignoreAbove() default @IntValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String indexOptions() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java index 379c825..13fb5b7 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongRangeField.java index 066973e..4980a50 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongRangeField.java @@ -28,8 +28,6 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticNestedField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticNestedField.java index 53b01cf..323c128 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticNestedField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticNestedField.java @@ -21,6 +21,4 @@ FieldType type = FieldType.NESTED; BoolValue dynamic() default @BoolValue(ignore = true); - - BoolValue includeInAll() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticObjectField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticObjectField.java index 0803955..fbfc93f 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticObjectField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticObjectField.java @@ -25,6 +25,4 @@ //If false, just store the field without indexing it. BoolValue enabledJson() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java index 3ffcd2b..b1f0112 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java @@ -33,8 +33,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java index e9d8820..de9bfd5 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java @@ -32,8 +32,6 @@ BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String nullValue() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTextField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTextField.java index b5e4c1e..936f185 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTextField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTextField.java @@ -41,8 +41,6 @@ FielddataFrequencyFilterValue fielddataFrequencyFilter() default @FielddataFrequ minSegmentSize = @IntValue(ignore = true) ); - BoolValue includeInAll() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); String indexOptions() default ""; diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java index 255570e..2071a80 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticTokenCountField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - BoolValue includeInAll() default @BoolValue(ignore = true); - String nullValue() default ""; BoolValue store() default @BoolValue(ignore = true); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/values/DateFieldValue.java b/src/main/java/org/frekele/elasticsearch/mapping/values/DateFieldValue.java index ee5d295..e102c0a 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/values/DateFieldValue.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/values/DateFieldValue.java @@ -23,8 +23,6 @@ public class DateFieldValue { private BoolValue ignoreMalformed; - private BoolValue includeInAll; - private BoolValue index; private String nullValue; @@ -32,7 +30,7 @@ public class DateFieldValue { private BoolValue store; public DateFieldValue(FieldType type, String suffixName, FloatValue boost, BoolValue docValues, - String format, String locale, BoolValue ignoreMalformed, BoolValue includeInAll, + String format, String locale, BoolValue ignoreMalformed, BoolValue index, String nullValue, BoolValue store) { this.type = type; this.suffixName = suffixName; @@ -41,7 +39,6 @@ public DateFieldValue(FieldType type, String suffixName, FloatValue boost, BoolV this.format = format; this.locale = locale; this.ignoreMalformed = ignoreMalformed; - this.includeInAll = includeInAll; this.index = index; this.nullValue = nullValue; this.store = store; @@ -75,10 +72,6 @@ public BoolValue getIgnoreMalformed() { return ignoreMalformed; } - public BoolValue getIncludeInAll() { - return includeInAll; - } - public BoolValue getIndex() { return index; } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java b/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java index 170fb45..0ff540e 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java @@ -22,8 +22,6 @@ public class NumericFieldValue { private BoolValue ignoreMalformed; - private BoolValue includeInAll; - private BoolValue index; private String nullValue; @@ -33,7 +31,7 @@ public class NumericFieldValue { private IntValue scalingFactor; public NumericFieldValue(FieldType type, String suffixName, BoolValue coerce, FloatValue boost, - BoolValue docValues, BoolValue ignoreMalformed, BoolValue includeInAll, + BoolValue docValues, BoolValue ignoreMalformed, BoolValue index, String nullValue, BoolValue store, IntValue scalingFactor) { this.type = type; this.suffixName = suffixName; @@ -41,7 +39,6 @@ public NumericFieldValue(FieldType type, String suffixName, BoolValue coerce, Fl this.boost = boost; this.docValues = docValues; this.ignoreMalformed = ignoreMalformed; - this.includeInAll = includeInAll; this.index = index; this.nullValue = nullValue; this.store = store; @@ -72,10 +69,6 @@ public BoolValue getIgnoreMalformed() { return ignoreMalformed; } - public BoolValue getIncludeInAll() { - return includeInAll; - } - public BoolValue getIndex() { return index; } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/values/RangeFieldValue.java b/src/main/java/org/frekele/elasticsearch/mapping/values/RangeFieldValue.java index 48c28a3..270dccb 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/values/RangeFieldValue.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/values/RangeFieldValue.java @@ -17,19 +17,16 @@ public class RangeFieldValue { private FloatValue boost; - private BoolValue includeInAll; - private BoolValue index; private BoolValue store; public RangeFieldValue(FieldType type, String suffixName, BoolValue coerce, FloatValue boost, - BoolValue includeInAll, BoolValue index, BoolValue store) { + BoolValue index, BoolValue store) { this.type = type; this.suffixName = suffixName; this.coerce = coerce; this.boost = boost; - this.includeInAll = includeInAll; this.index = index; this.store = store; } @@ -50,10 +47,6 @@ public FloatValue getBoost() { return boost; } - public BoolValue getIncludeInAll() { - return includeInAll; - } - public BoolValue getIndex() { return index; } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index e6fa554..e724ea1 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -79,7 +79,7 @@ public void buildTest() throws Exception { @Test public void buildTest2() throws Exception { - String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"include_in_all\":true,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"include_in_all\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"include_in_all\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"include_in_all\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"include_in_all\":true,\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"include_in_all\":true,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentTwoEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); From 19bbd157781217945395e4a240ca7ce9937b2c99 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 12:01:16 +0100 Subject: [PATCH 06/14] remove includeInAll --- README.md | 22 ------------------- .../generic/FullDocumentTwoEntity.java | 21 ------------------ 2 files changed, 43 deletions(-) diff --git a/README.md b/README.md index 7c4e07e..2e98308 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,6 @@ public class EmployeeEntity { @ElasticDocument( value = "my_doc_type", dynamic = @BoolValue(true), - includeInAll = @BoolValue(true), parent = "my_parent_doc_type", //add eager_global_ordinals into _parent eagerGlobalOrdinalsParent = @BoolValue(true), @@ -222,7 +221,6 @@ private Boolean booleanValue; boost = @FloatValue(0.2f), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -252,7 +250,6 @@ private String completionValue; format = "basic_date_time", locale = "en-US", ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -269,7 +266,6 @@ private Date dateValue; format = "basic_date_time", locale = "en-US", ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -285,7 +281,6 @@ private Date dateRangeValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -299,7 +294,6 @@ private Double doubleValue; suffixName = "doubleRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -314,7 +308,6 @@ private Double doubleRangeValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -328,7 +321,6 @@ private Float floatValue; suffixName = "floatRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -367,7 +359,6 @@ private String geoShapeValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -383,7 +374,6 @@ private Float halfFloatValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -397,7 +387,6 @@ private Integer integerValue; suffixName = "integerRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -410,7 +399,6 @@ private Integer integerRangeValue; suffixName = "ip", boost = @FloatValue(1), docValues = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -424,7 +412,6 @@ private String ipValue; suffixName = "ipRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -440,7 +427,6 @@ private String ipRangeValue; docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), ignoreAbove = @IntValue(350), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "docs", norms = @BoolValue(true), @@ -460,7 +446,6 @@ private String keywordValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -474,7 +459,6 @@ private Long longValue; suffixName = "longRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -497,7 +481,6 @@ private String percolatorValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true), @@ -514,7 +497,6 @@ private Float scaledFloatValue; boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -535,7 +517,6 @@ private Short shortValue; max = @FloatValue(0.1f), minSegmentSize = @IntValue(500) ), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "", norms = @BoolValue(true), @@ -559,7 +540,6 @@ private String textValue; boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - includeInAll = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) ) @@ -606,7 +586,6 @@ private String customValue; max = @FloatValue(0.1f), minSegmentSize = @IntValue(500) ), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "", norms = @BoolValue(true), @@ -625,7 +604,6 @@ private String customValue; docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), ignoreAbove = @IntValue(350), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "docs", norms = @BoolValue(true), diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java index b108d8a..7a2d881 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java @@ -59,7 +59,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(0.2f), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -83,7 +82,6 @@ public class FullDocumentTwoEntity { format = "basic_date_time", locale = "en-US", ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -97,7 +95,6 @@ public class FullDocumentTwoEntity { format = "basic_date_time", locale = "en-US", ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -110,7 +107,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -121,7 +117,6 @@ public class FullDocumentTwoEntity { suffixName = "doubleRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -133,7 +128,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -144,7 +138,6 @@ public class FullDocumentTwoEntity { suffixName = "floatRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -174,7 +167,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -187,7 +179,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -198,7 +189,6 @@ public class FullDocumentTwoEntity { suffixName = "integerRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -208,7 +198,6 @@ public class FullDocumentTwoEntity { suffixName = "ip", boost = @FloatValue(1), docValues = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -219,7 +208,6 @@ public class FullDocumentTwoEntity { suffixName = "ipRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -232,7 +220,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), ignoreAbove = @IntValue(350), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "docs", norms = @BoolValue(true), @@ -249,7 +236,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -260,7 +246,6 @@ public class FullDocumentTwoEntity { suffixName = "longRange", coerce = @BoolValue(true), boost = @FloatValue(1), - includeInAll = @BoolValue(true), index = @BoolValue(true), store = @BoolValue(true) ) @@ -277,7 +262,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true), @@ -291,7 +275,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), - includeInAll = @BoolValue(true), index = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) @@ -309,7 +292,6 @@ public class FullDocumentTwoEntity { max = @FloatValue(0.1f), minSegmentSize = @IntValue(500) ), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "", norms = @BoolValue(true), @@ -330,7 +312,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - includeInAll = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true) ) @@ -365,7 +346,6 @@ public class FullDocumentTwoEntity { max = @FloatValue(0.1f), minSegmentSize = @IntValue(500) ), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "", norms = @BoolValue(true), @@ -384,7 +364,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), ignoreAbove = @IntValue(350), - includeInAll = @BoolValue(true), index = @BoolValue(true), indexOptions = "docs", norms = @BoolValue(true), From e5997dc389ea8cf03805b20479295adf25e500bf Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 12:06:44 +0100 Subject: [PATCH 07/14] remove nullValue from Numeric --- .../mapping/MappingBuilderImpl.java | 18 ++++++++---------- .../annotations/ElasticBooleanField.java | 2 -- .../mapping/annotations/ElasticByteField.java | 2 -- .../annotations/ElasticDoubleField.java | 2 -- .../mapping/annotations/ElasticFloatField.java | 2 -- .../annotations/ElasticHalfFloatField.java | 2 -- .../annotations/ElasticIntegerField.java | 2 -- .../mapping/annotations/ElasticLongField.java | 2 -- .../annotations/ElasticScaledFloatField.java | 2 -- .../mapping/annotations/ElasticShortField.java | 2 -- .../mapping/values/NumericFieldValue.java | 9 +-------- .../mapping/MappingBuilderTest.java | 2 +- .../generic/FullDocumentTwoEntity.java | 15 ++------------- 13 files changed, 12 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java index e914780..63cde03 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java @@ -514,7 +514,6 @@ public void processElasticField(NumericFieldValue vo, boolean subField) throws I this.docValues(vo.getDocValues()); this.ignoreMalformed(vo.getIgnoreMalformed()); this.index(vo.getIndex()); - this.nullValue(vo.getNullValue()); this.store(vo.getStore()); this.scalingFactor(vo.getScalingFactor()); this.closeSuffixName(subField); @@ -523,56 +522,56 @@ public void processElasticField(NumericFieldValue vo, boolean subField) throws I public void processElasticField(ElasticLongField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticIntegerField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticShortField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticByteField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticDoubleField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticHalfFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), null); + elasticField.index(), elasticField.store(), null); this.processElasticField(vo, subField); } public void processElasticField(ElasticScaledFloatField elasticField, boolean subField) throws IOException { NumericFieldValue vo = new NumericFieldValue(elasticField.type, elasticField.suffixName(), elasticField.coerce(), elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store(), elasticField.scalingFactor()); + elasticField.index(), elasticField.store(), elasticField.scalingFactor()); this.processElasticField(vo, subField); } @@ -589,7 +588,6 @@ public void processElasticField(ElasticBooleanField elasticField, boolean subFie this.boost(elasticField.boost()); this.docValues(elasticField.docValues()); this.index(elasticField.index()); - this.nullValue(elasticField.nullValue()); this.store(elasticField.store()); this.closeSuffixName(subField); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticBooleanField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticBooleanField.java index a4e93f7..9b568c9 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticBooleanField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticBooleanField.java @@ -31,7 +31,5 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java index 595f1fb..f78b240 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java index 23419fc..4b99b71 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java index 6dad1b9..bac2a9f 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java index ddb3cdd..df7feb3 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java index 5498527..26a09f2 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java index 13fb5b7..a39951b 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java index b1f0112..ca58bd6 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java @@ -35,8 +35,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); IntValue scalingFactor(); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java index de9bfd5..5ca0d0d 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java @@ -34,8 +34,6 @@ BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java b/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java index 0ff540e..241fc22 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java @@ -24,15 +24,13 @@ public class NumericFieldValue { private BoolValue index; - private String nullValue; - private BoolValue store; private IntValue scalingFactor; public NumericFieldValue(FieldType type, String suffixName, BoolValue coerce, FloatValue boost, BoolValue docValues, BoolValue ignoreMalformed, - BoolValue index, String nullValue, BoolValue store, IntValue scalingFactor) { + BoolValue index, BoolValue store, IntValue scalingFactor) { this.type = type; this.suffixName = suffixName; this.coerce = coerce; @@ -40,7 +38,6 @@ public NumericFieldValue(FieldType type, String suffixName, BoolValue coerce, Fl this.docValues = docValues; this.ignoreMalformed = ignoreMalformed; this.index = index; - this.nullValue = nullValue; this.store = store; this.scalingFactor = scalingFactor; } @@ -73,10 +70,6 @@ public BoolValue getIndex() { return index; } - public String getNullValue() { - return nullValue; - } - public BoolValue getStore() { return store; } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index e724ea1..ac31d80 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -79,7 +79,7 @@ public void buildTest() throws Exception { @Test public void buildTest2() throws Exception { - String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentTwoEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java index 7a2d881..041b20f 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java @@ -49,7 +49,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true)) private Boolean booleanValue; @@ -60,7 +59,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Byte byteValue; @@ -108,7 +106,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Double doubleValue; @@ -129,7 +126,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Float floatValue; @@ -168,7 +164,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Float halfFloatValue; @@ -180,7 +175,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Integer integerValue; @@ -237,7 +231,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Long longValue; @@ -263,7 +256,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true), scalingFactor = @IntValue(100) ) @@ -276,7 +268,6 @@ public class FullDocumentTwoEntity { docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Short shortValue; @@ -318,15 +309,13 @@ public class FullDocumentTwoEntity { private String tokenCountValue; @ElasticNestedField( - dynamic = @BoolValue(true), - includeInAll = @BoolValue(true) + dynamic = @BoolValue(true) ) private InnerDocumentEntity nestedValue; @ElasticObjectField( dynamic = @BoolValue(true), - enabledJson = @BoolValue(true), - includeInAll = @BoolValue(true) + enabledJson = @BoolValue(true) ) private InnerDocumentEntity objectValue; From c562f8884a3029334f0828cda82eb7f081576ce8 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 12:08:36 +0100 Subject: [PATCH 08/14] remove nullValue from Numeric from README.md --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 2e98308..746740a 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,6 @@ private String binaryValue; boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true)) private Boolean booleanValue; ``` @@ -222,7 +221,6 @@ private Boolean booleanValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Byte byteValue; @@ -282,7 +280,6 @@ private Date dateRangeValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Double doubleValue; @@ -309,7 +306,6 @@ private Double doubleRangeValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Float floatValue; @@ -360,7 +356,6 @@ private String geoShapeValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Float halfFloatValue; @@ -375,7 +370,6 @@ private Float halfFloatValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Integer integerValue; @@ -447,7 +441,6 @@ private String keywordValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Long longValue; @@ -482,7 +475,6 @@ private String percolatorValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true), scalingFactor = @IntValue(100) ) @@ -498,7 +490,6 @@ private Float scaledFloatValue; docValues = @BoolValue(true), ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Short shortValue; From 37b048243807964f4014394568f81d6e76490e95 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 12:32:42 +0100 Subject: [PATCH 09/14] MappingBuilderTest build2 is valid against elasticsearch --- .../mapping/MappingBuilderImpl.java | 34 ++-------------- .../annotations/ElasticDateRangeField.java | 6 --- .../annotations/ElasticGeoShapeField.java | 6 +++ .../mapping/MappingBuilderTest.java | 2 +- .../generic/FullDocumentTwoEntity.java | 39 +++++++------------ 5 files changed, 25 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java index 63cde03..c2252f9 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java @@ -3,35 +3,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; -import org.frekele.elasticsearch.mapping.annotations.ElasticBinaryField; -import org.frekele.elasticsearch.mapping.annotations.ElasticBooleanField; -import org.frekele.elasticsearch.mapping.annotations.ElasticByteField; -import org.frekele.elasticsearch.mapping.annotations.ElasticCompletionField; -import org.frekele.elasticsearch.mapping.annotations.ElasticCustomJsonField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDateField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDateRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; -import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticFloatField; -import org.frekele.elasticsearch.mapping.annotations.ElasticFloatRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticGeoPointField; -import org.frekele.elasticsearch.mapping.annotations.ElasticGeoShapeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticHalfFloatField; -import org.frekele.elasticsearch.mapping.annotations.ElasticIntegerField; -import org.frekele.elasticsearch.mapping.annotations.ElasticIntegerRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticIpField; -import org.frekele.elasticsearch.mapping.annotations.ElasticIpRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; -import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; -import org.frekele.elasticsearch.mapping.annotations.ElasticLongRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticNestedField; -import org.frekele.elasticsearch.mapping.annotations.ElasticObjectField; -import org.frekele.elasticsearch.mapping.annotations.ElasticPercolatorField; -import org.frekele.elasticsearch.mapping.annotations.ElasticScaledFloatField; -import org.frekele.elasticsearch.mapping.annotations.ElasticShortField; -import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; -import org.frekele.elasticsearch.mapping.annotations.ElasticTokenCountField; +import org.frekele.elasticsearch.mapping.annotations.*; import org.frekele.elasticsearch.mapping.annotations.values.BoolValue; import org.frekele.elasticsearch.mapping.annotations.values.FielddataFrequencyFilterValue; import org.frekele.elasticsearch.mapping.annotations.values.FloatValue; @@ -656,8 +628,8 @@ public void processElasticField(DateFieldValue vo, boolean subField) throws IOEx public void processElasticField(ElasticDateRangeField elasticField, boolean subField) throws IOException { DateFieldValue vo = new DateFieldValue(elasticField.type, elasticField.suffixName(), elasticField.boost(), - elasticField.docValues(), elasticField.format(), elasticField.locale(), elasticField.ignoreMalformed(), - elasticField.index(), elasticField.nullValue(), elasticField.store()); + null, elasticField.format(), elasticField.locale(), null, + elasticField.index(), null, elasticField.store()); this.processElasticField(vo, subField); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java index 0a51ab8..dfa0dca 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDateRangeField.java @@ -26,18 +26,12 @@ @Deprecated FloatValue boost() default @FloatValue(ignore = true); - BoolValue docValues() default @BoolValue(ignore = true); - String format() default ""; String locale() default ""; - BoolValue ignoreMalformed() default @BoolValue(ignore = true); - BoolValue index() default @BoolValue(ignore = true); - String nullValue() default ""; - BoolValue store() default @BoolValue(ignore = true); } diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticGeoShapeField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticGeoShapeField.java index bbb436f..57192d8 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticGeoShapeField.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticGeoShapeField.java @@ -24,18 +24,24 @@ String suffixName() default "geoShape"; + @Deprecated String tree() default ""; + @Deprecated String precision() default ""; + @Deprecated String treeLevels() default ""; + @Deprecated String strategy() default ""; + @Deprecated FloatValue distanceErrorPct() default @FloatValue(ignore = true); String orientation() default ""; + @Deprecated BoolValue pointsOnly() default @BoolValue(ignore = true); } diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index ac31d80..fb324c5 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -79,7 +79,7 @@ public void buildTest() throws Exception { @Test public void buildTest2() throws Exception { - String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"kilometers\",\"tree_levels\":\"50m\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"myAnalyzer\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"mySearchAnalyzer\",\"search_quote_analyzer\":\"my_analyzer\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"analyzer\":\"myAnalyzer\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\",\"normalizer\":\"my_normalizer\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"myAnalyzer\",\"search_analyzer\":\"mySearchAnalyzer\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; + String expected = "{\"mappings\":{\"properties\":{\"binaryValue\":{\"type\":\"binary\",\"doc_values\":true,\"store\":true},\"booleanValue\":{\"type\":\"boolean\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"store\":true},\"byteValue\":{\"type\":\"byte\",\"coerce\":true,\"boost\":0.2,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"completionValue\":{\"type\":\"completion\",\"analyzer\":\"standard\",\"search_analyzer\":\"standard\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50},\"dateValue\":{\"type\":\"date\",\"boost\":1.0,\"doc_values\":true,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"ignore_malformed\":true,\"index\":true,\"null_value\":\"NULL\",\"store\":true},\"dateRangeValue\":{\"type\":\"date_range\",\"boost\":1.0,\"format\":\"basic_date_time\",\"locale\":\"en-US\",\"index\":true,\"store\":true},\"doubleValue\":{\"type\":\"double\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"doubleRangeValue\":{\"type\":\"double_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"floatValue\":{\"type\":\"float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"floatRangeValue\":{\"type\":\"float_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"geoPointValue\":{\"type\":\"geo_point\",\"ignore_malformed\":true},\"geoShapeValue\":{\"type\":\"geo_shape\",\"tree\":\"geohash\",\"precision\":\"1m\",\"tree_levels\":\"12\",\"strategy\":\"recursive\",\"distance_error_pct\":0.025,\"orientation\":\"ccw\",\"points_only\":false},\"halfFloatValue\":{\"type\":\"half_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerValue\":{\"type\":\"integer\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"integerRangeValue\":{\"type\":\"integer_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"ipValue\":{\"type\":\"ip\",\"boost\":1.0,\"doc_values\":true,\"index\":true,\"store\":true},\"ipRangeValue\":{\"type\":\"ip_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"keywordValue\":{\"type\":\"keyword\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\"},\"longValue\":{\"type\":\"long\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"longRangeValue\":{\"type\":\"long_range\",\"coerce\":true,\"boost\":1.0,\"index\":true,\"store\":true},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true,\"scaling_factor\":100},\"shortValue\":{\"type\":\"short\",\"coerce\":true,\"boost\":1.0,\"doc_values\":true,\"ignore_malformed\":true,\"index\":true,\"store\":true},\"textValue\":{\"type\":\"text\",\"analyzer\":\"standard\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"standard\",\"search_quote_analyzer\":\"standard\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\",\"enable_position_increments\":true,\"boost\":1.0,\"doc_values\":true,\"index\":true,\"store\":true},\"nestedValue\":{\"type\":\"nested\",\"dynamic\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"objectValue\":{\"dynamic\":true,\"enabled\":true,\"properties\":{\"binaryValue\":{\"type\":\"binary\"},\"booleanValue\":{\"type\":\"boolean\"},\"byteValue\":{\"type\":\"byte\"},\"completionValue\":{\"type\":\"completion\"},\"dateValue\":{\"type\":\"date\"},\"dateRangeValue\":{\"type\":\"date_range\"},\"doubleValue\":{\"type\":\"double\"},\"doubleRangeValue\":{\"type\":\"double_range\"},\"floatValue\":{\"type\":\"float\"},\"floatRangeValue\":{\"type\":\"float_range\"},\"geoPointValue\":{\"type\":\"geo_point\"},\"geoShapeValue\":{\"type\":\"geo_shape\"},\"halfFloatValue\":{\"type\":\"half_float\"},\"integerValue\":{\"type\":\"integer\"},\"integerRangeValue\":{\"type\":\"integer_range\"},\"ipValue\":{\"type\":\"ip\"},\"ipRangeValue\":{\"type\":\"ip_range\"},\"keywordValue\":{\"type\":\"keyword\"},\"longValue\":{\"type\":\"long\"},\"longRangeValue\":{\"type\":\"long_range\"},\"percolatorValue\":{\"type\":\"percolator\"},\"scaledFloatValue\":{\"type\":\"scaled_float\",\"scaling_factor\":50},\"shortValue\":{\"type\":\"short\"},\"textValue\":{\"type\":\"text\"},\"tokenCountValue\":{\"type\":\"token_count\",\"analyzer\":\"standard\"}}},\"customValue\":{\"type\": \"text\",\"fields\":{\"customKeyword\":{\"type\": \"keyword\",\"ignore_above\":256 }}},\"multiFieldValue\":{\"type\":\"text\",\"analyzer\":\"standard\",\"boost\":1.0,\"eager_global_ordinals\":true,\"fielddata\":true,\"fielddata_frequency_filter\":{\"min\":0.001,\"max\":0.1,\"min_segment_size\":500},\"index\":true,\"norms\":true,\"position_increment_gap\":100,\"store\":true,\"search_analyzer\":\"standard\",\"search_quote_analyzer\":\"standard\",\"similarity\":\"BM25\",\"term_vector\":\"no\",\"copy_to\":\"anotherField\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"boost\":1.0,\"doc_values\":true,\"eager_global_ordinals\":true,\"ignore_above\":350,\"index\":true,\"index_options\":\"docs\",\"norms\":true,\"null_value\":\"NULL\",\"store\":true,\"similarity\":\"BM25\"},\"completion\":{\"type\":\"completion\",\"analyzer\":\"standard\",\"search_analyzer\":\"standard\",\"preserve_separators\":true,\"preserve_position_increments\":true,\"max_input_length\":50}}}}}}"; MappingBuilder mappingBuilder = new MappingBuilderImpl(); ObjectMapping result = mappingBuilder.build(FullDocumentTwoEntity.class); assertEquals(result.getContentAsString().replaceAll("[\\r\\n]", ""), expected); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java index 041b20f..af1b8d6 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java @@ -65,8 +65,8 @@ public class FullDocumentTwoEntity { @ElasticCompletionField( suffixName = "completion", - analyzer = "myAnalyzer", - searchAnalyzer = "mySearchAnalyzer", + analyzer = "standard", + searchAnalyzer = "standard", preserveSeparators = @BoolValue(true), preservePositionIncrements = @BoolValue(true), maxInputLength = @IntValue(50) @@ -89,12 +89,9 @@ public class FullDocumentTwoEntity { @ElasticDateRangeField( suffixName = "dateRange", boost = @FloatValue(1), - docValues = @BoolValue(true), format = "basic_date_time", locale = "en-US", - ignoreMalformed = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private Date dateRangeValue; @@ -148,8 +145,8 @@ public class FullDocumentTwoEntity { @ElasticGeoShapeField( suffixName = "geoShape", tree = "geohash", - precision = "kilometers", - treeLevels = "50m", + precision = "1m", + treeLevels = "12", strategy = "recursive", distanceErrorPct = @FloatValue(0.025f), orientation = "ccw", @@ -193,7 +190,6 @@ public class FullDocumentTwoEntity { boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private String ipValue; @@ -209,7 +205,6 @@ public class FullDocumentTwoEntity { @ElasticKeywordField( suffixName = "keyword", - analyzer = "myAnalyzer", boost = @FloatValue(1), docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), @@ -219,8 +214,7 @@ public class FullDocumentTwoEntity { norms = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true), - similarity = "BM25", - normalizer = "my_normalizer" + similarity = "BM25" ) private String keywordValue; @@ -274,7 +268,7 @@ public class FullDocumentTwoEntity { @ElasticTextField( suffixName = "text", - analyzer = "myAnalyzer", + analyzer = "standard", boost = @FloatValue(1), eagerGlobalOrdinals = @BoolValue(true), fielddata = @BoolValue(true), @@ -288,8 +282,8 @@ public class FullDocumentTwoEntity { norms = @BoolValue(true), positionIncrementGap = @IntValue(100), store = @BoolValue(true), - searchAnalyzer = "mySearchAnalyzer", - searchQuoteAnalyzer = "my_analyzer", + searchAnalyzer = "standard", + searchQuoteAnalyzer = "standard", similarity = "BM25", termVector = "no", copyTo = {"anotherField"} @@ -298,12 +292,11 @@ public class FullDocumentTwoEntity { @ElasticTokenCountField( suffixName = "tokenCount", - analyzer = "myAnalyzer", + analyzer = "standard", enablePositionIncrements = @BoolValue(true), boost = @FloatValue(1), docValues = @BoolValue(true), index = @BoolValue(true), - nullValue = "NULL", store = @BoolValue(true) ) private String tokenCountValue; @@ -326,7 +319,7 @@ public class FullDocumentTwoEntity { @ElasticTextField( suffixName = "text", - analyzer = "myAnalyzer", + analyzer = "standard", boost = @FloatValue(1), eagerGlobalOrdinals = @BoolValue(true), fielddata = @BoolValue(true), @@ -340,15 +333,14 @@ public class FullDocumentTwoEntity { norms = @BoolValue(true), positionIncrementGap = @IntValue(100), store = @BoolValue(true), - searchAnalyzer = "mySearchAnalyzer", - searchQuoteAnalyzer = "my_analyzer", + searchAnalyzer = "standard", + searchQuoteAnalyzer = "standard", similarity = "BM25", termVector = "no", copyTo = {"anotherField"} ) @ElasticKeywordField( suffixName = "keyword", - analyzer = "myAnalyzer", boost = @FloatValue(1), docValues = @BoolValue(true), eagerGlobalOrdinals = @BoolValue(true), @@ -358,13 +350,12 @@ public class FullDocumentTwoEntity { norms = @BoolValue(true), nullValue = "NULL", store = @BoolValue(true), - similarity = "BM25", - normalizer = "my_normalizer" + similarity = "BM25" ) @ElasticCompletionField( suffixName = "completion", - analyzer = "myAnalyzer", - searchAnalyzer = "mySearchAnalyzer", + analyzer = "standard", + searchAnalyzer = "standard", preserveSeparators = @BoolValue(true), preservePositionIncrements = @BoolValue(true), maxInputLength = @IntValue(50) From 94029234f9fea0af41a39c7b8077740badb94021 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 13:17:59 +0100 Subject: [PATCH 10/14] remove ElasticDocument --- pom.xml | 2 +- .../mapping/MappingBuilderImpl.java | 22 -------------- .../mapping/annotations/ElasticDocument.java | 30 ------------------- .../mapping/MappingBuilderTest.java | 30 ------------------- .../entities/generic/FullDocumentEntity.java | 2 -- .../generic/FullDocumentTwoEntity.java | 2 -- .../IncorrectCustomJsonFieldEntity.java | 2 -- .../generic/RecursiveErrorDocumentEntity.java | 2 -- .../mapping/entities/model/AuthorEntity.java | 2 -- .../mapping/entities/model/BookEntity.java | 2 -- .../entities/model/EmployeeEntity.java | 2 -- .../mapping/entities/model/PersonEntity.java | 3 -- .../mapping/entities/model/ProductEntity.java | 2 -- 13 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java diff --git a/pom.xml b/pom.xml index 2c0e607..1eec035 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.frekele.elasticsearch elasticsearch-mapping-builder - 1.0.8-SNAPSHOT + 1.1.0 jar 2017 diff --git a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java index c2252f9..5d5a04f 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/MappingBuilderImpl.java @@ -56,7 +56,6 @@ public ObjectMapping build(boolean pretty, Class documentClass) { } else { this.docsClass = documentClass; } - this.validateElasticDocument(); try { XContentBuilder xContentBuilder = this.innerBuild(pretty); return new ObjectMapping(xContentBuilder); @@ -77,16 +76,6 @@ private void setMapping(XContentBuilder mapping) { this.mapping = mapping; } - public static boolean isElasticDocument(Class documentClass) { - return (documentClass.isAnnotationPresent(ElasticDocument.class)); - } - - public void validateElasticDocument() { - if (!isElasticDocument(this.getDocClass())) { - throw new InvalidDocumentClassException("Document Class[" + this.getDocClass().getCanonicalName() + "] Invalid. @ElasticDocument must be present."); - } - } - public static List getElasticFieldAnnotations(Field field) { List result = new ArrayList<>(); Annotation[] annotations = field.getDeclaredAnnotations(); @@ -790,17 +779,6 @@ public XContentBuilder innerBuild(boolean pretty) throws IOException { this.getMapping().startObject(); this.getMapping().startObject("mappings"); - ElasticDocument elasticDocument = (ElasticDocument) this.getDocClass().getAnnotation(ElasticDocument.class); - - //_routing - if (isValueEnabled(elasticDocument.requiredRouting())) { - this.getMapping().startObject("_routing"); - this.getMapping().field("required", elasticDocument.requiredRouting().value()); - this.getMapping().endObject(); - } - - this.dynamic(elasticDocument.dynamic()); - Field[] fields = this.getDocClass().getDeclaredFields(); this.recursiveFields(fields, 0); diff --git a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java deleted file mode 100644 index 9877051..0000000 --- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.frekele.elasticsearch.mapping.annotations; - -import org.frekele.elasticsearch.mapping.annotations.values.BoolValue; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Elasticsearch Document Type. - * - * @author frekele - Leandro Kersting de Freitas - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface ElasticDocument { - - //Document name Type. - String value(); - - BoolValue dynamic() default @BoolValue(ignore = true); - - //add eager_global_ordinals into _parent - BoolValue eagerGlobalOrdinalsParent() default @BoolValue(ignore = true); - - //add required into _routing - BoolValue requiredRouting() default @BoolValue(ignore = true); - -} diff --git a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java index fb324c5..24921b3 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/MappingBuilderTest.java @@ -25,36 +25,6 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - @Test - public void isElasticDocumentTest() throws Exception { - boolean result = MappingBuilderImpl.isElasticDocument(FullDocumentEntity.class); - assertEquals(result, true); - - result = MappingBuilderImpl.isElasticDocument(NoDocumentEntity.class); - assertEquals(result, false); - } - - @Test - public void validateWithoutErrorTest() throws Exception { - MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); - mappingBuilder.build(FullDocumentEntity.class); - mappingBuilder.validateElasticDocument(); - } - - @Test(expectedExceptions = InvalidDocumentClassException.class) - public void validateWithErrorTest() throws Exception { - MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); - mappingBuilder.build(NoDocumentEntity.class); - mappingBuilder.validateElasticDocument(); - } - - @Test(expectedExceptions = MappingBuilderException.class) - public void validateWithErrorTest2() throws Exception { - MappingBuilderImpl mappingBuilder = new MappingBuilderImpl(); - mappingBuilder.build(null); - mappingBuilder.validateElasticDocument(); - } - @Test(expectedExceptions = InvalidCustomJsonException.class) public void buildWithErrorElasticCustomJsonFieldTest() throws Exception { MappingBuilder mappingBuilder = new MappingBuilderImpl(); diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java index 2fc18e5..8b54a92 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java @@ -7,7 +7,6 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticCustomJsonField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleField; import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleRangeField; import org.frekele.elasticsearch.mapping.annotations.ElasticFloatField; @@ -33,7 +32,6 @@ import java.util.Date; -@ElasticDocument("full") public class FullDocumentEntity { @ElasticBinaryField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java index af1b8d6..ac12060 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java @@ -7,7 +7,6 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticCustomJsonField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateRangeField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleField; import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleRangeField; import org.frekele.elasticsearch.mapping.annotations.ElasticFloatField; @@ -36,7 +35,6 @@ import java.util.Date; -@ElasticDocument("full_two") public class FullDocumentTwoEntity { @ElasticBinaryField( diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/IncorrectCustomJsonFieldEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/IncorrectCustomJsonFieldEntity.java index 99e4d95..54c4798 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/IncorrectCustomJsonFieldEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/IncorrectCustomJsonFieldEntity.java @@ -1,9 +1,7 @@ package org.frekele.elasticsearch.mapping.entities.generic; import org.frekele.elasticsearch.mapping.annotations.ElasticCustomJsonField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; -@ElasticDocument("incorrect") public class IncorrectCustomJsonFieldEntity { @ElasticCustomJsonField(path = "/custom/mapping/invalid-not-exist.json") diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/RecursiveErrorDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/RecursiveErrorDocumentEntity.java index 64b851b..6fd76b2 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/RecursiveErrorDocumentEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/RecursiveErrorDocumentEntity.java @@ -1,11 +1,9 @@ package org.frekele.elasticsearch.mapping.entities.generic; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; import org.frekele.elasticsearch.mapping.annotations.ElasticObjectField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; -@ElasticDocument("recursive_doc") public class RecursiveErrorDocumentEntity { @ElasticLongField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/AuthorEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/AuthorEntity.java index 885938f..d6ccb8f 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/AuthorEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/AuthorEntity.java @@ -1,12 +1,10 @@ package org.frekele.elasticsearch.mapping.entities.model; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; import org.frekele.elasticsearch.mapping.annotations.ElasticNestedField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; -@ElasticDocument(value = "author") public class AuthorEntity { @ElasticLongField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java index 3b67411..0f6616f 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/BookEntity.java @@ -5,13 +5,11 @@ import org.frekele.elasticsearch.mapping.annotations.ElasticBinaryField; import org.frekele.elasticsearch.mapping.annotations.ElasticBooleanField; import org.frekele.elasticsearch.mapping.annotations.ElasticDateField; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; import org.frekele.elasticsearch.mapping.annotations.ElasticObjectField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; import org.frekele.elasticsearch.mapping.annotations.values.BoolValue; -@ElasticDocument("book") public class BookEntity { @ElasticKeywordField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java index 76fed08..a14571d 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/EmployeeEntity.java @@ -1,11 +1,9 @@ package org.frekele.elasticsearch.mapping.entities.model; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; import org.frekele.elasticsearch.mapping.annotations.ElasticTextField; -@ElasticDocument(value = "employee") public class EmployeeEntity { @ElasticLongField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/PersonEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/PersonEntity.java index 08848d2..d410922 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/PersonEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/PersonEntity.java @@ -1,6 +1,5 @@ package org.frekele.elasticsearch.mapping.entities.model; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticKeywordField; import org.frekele.elasticsearch.mapping.annotations.ElasticLongField; import org.frekele.elasticsearch.mapping.annotations.ElasticObjectField; @@ -8,8 +7,6 @@ import java.util.List; -@ElasticDocument(value = "person") - public class PersonEntity { @ElasticLongField diff --git a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/ProductEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/ProductEntity.java index a1d66bf..4383610 100644 --- a/src/test/java/org/frekele/elasticsearch/mapping/entities/model/ProductEntity.java +++ b/src/test/java/org/frekele/elasticsearch/mapping/entities/model/ProductEntity.java @@ -1,6 +1,5 @@ package org.frekele.elasticsearch.mapping.entities.model; -import org.frekele.elasticsearch.mapping.annotations.ElasticDocument; import org.frekele.elasticsearch.mapping.annotations.ElasticDoubleField; import org.frekele.elasticsearch.mapping.annotations.ElasticFloatField; import org.frekele.elasticsearch.mapping.annotations.ElasticIntegerField; @@ -8,7 +7,6 @@ import java.util.List; -@ElasticDocument("product") public class ProductEntity { @ElasticLongField From 8dbb1b37d076082edec6c613270306d05536e8c1 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 14:46:34 +0100 Subject: [PATCH 11/14] update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 746740a..e532991 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/778eee87938f43ca92a94b7b613a0891)](https://www.codacy.com/app/frekele/elasticsearch-mapping-builder?utm_source=github.com&utm_medium=referral&utm_content=frekele/elasticsearch-mapping-builder&utm_campaign=Badge_Coverage) - Built-based on the documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/5.x/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/mapping.html) + Built-based on the documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping.html) #### Compatibility: | Elasticsearch Mapping Builder | Elasticsearch | | ------------------------------| ---------------------- | -| Version: 1.0.7 | Version: 7.x.x | +| Version: 1.1.0 | Version: 7.x.x | #### Maven dependency: @@ -22,13 +22,13 @@ org.frekele.elasticsearch elasticsearch-mapping-builder - 1.0.7 + 1.1.0 ``` #### Gradle dependency: ```gradle -implementation 'org.frekele.elasticsearch:elasticsearch-mapping-builder:1.0.7' +implementation 'org.frekele.elasticsearch:elasticsearch-mapping-builder:1.1.0' ``` #### Build From 2263e17c72e82b7f91158df7b3099324c7c8a465 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 15:42:48 +0100 Subject: [PATCH 12/14] update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e532991..1cd08e5 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/778eee87938f43ca92a94b7b613a0891)](https://www.codacy.com/app/frekele/elasticsearch-mapping-builder?utm_source=github.com&utm_medium=referral&utm_content=frekele/elasticsearch-mapping-builder&utm_campaign=Badge_Coverage) - Built-based on the documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping.html) + Built-based on the documentation: [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) #### Compatibility: -| Elasticsearch Mapping Builder | Elasticsearch | -| ------------------------------| ---------------------- | -| Version: 1.1.0 | Version: 7.x.x | +| Elasticsearch Mapping Builder | Elasticsearch | +| ------------------------------| ---------------------------------------------------------------------------------------- | +| Version: 1.0.7 | Version: [5.x](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/mapping.html) | +| Version: 1.1.0 | Version: [7.x](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping.html) | #### Maven dependency: From 88d85186dfc8c31e50d31917ebfd50996b090680 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 26 Mar 2020 15:53:27 +0100 Subject: [PATCH 13/14] add example usage with scala --- README.md | 100 +++++++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 1cd08e5..f1cbd3e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,6 @@ public String getMapping() { ``` ```java -@ElasticDocument("book") public class BookEntity { @ElasticKeywordField @@ -90,7 +89,6 @@ public class BookEntity { ......... } -@ElasticDocument(value = "author") public class AuthorEntity { @ElasticLongField @@ -107,13 +105,13 @@ public class AuthorEntity { } ``` -**Person parent and Employee:** +**Employee:** ```java @Inject MappingBuilder mappingBuilder; public String getMapping() { - return mappingBuilder.build(PersonEntity.class, EmployeeEntity.class).getContentAsString(); + return mappingBuilder.build(EmployeeEntity.class).getContentAsString(); } ``` @@ -134,32 +132,6 @@ public class AddressEntity { ......... } -public class PersonEntity { - - @ElasticLongField - private Long id; - - @ElasticTextField - @ElasticKeywordField - private String name; - - @ElasticTextField - @ElasticKeywordField - private String fullName; - - @ElasticTextField(copyTo = {"name", "fullName"}) - private String fistName; - - @ElasticTextField(copyTo = {"fullName"}) - private String lastName; - - @ElasticObjectField - private List multipleAddress; - - ......... -} - -@ElasticDocument(value = "employee", parent = "person") public class EmployeeEntity { @ElasticLongField @@ -178,22 +150,6 @@ public class EmployeeEntity { #### Annotations parameters: -###### ElasticDocument -```java -@ElasticDocument( - value = "my_doc_type", - dynamic = @BoolValue(true), - parent = "my_parent_doc_type", - //add eager_global_ordinals into _parent - eagerGlobalOrdinalsParent = @BoolValue(true), - //add required into _routing - requiredRouting = @BoolValue(true) -) -public class MyDocumentEntity { - ......... -``` - - ###### ElasticBinaryField ```java @ElasticBinaryField( @@ -615,6 +571,58 @@ private String customValue; private String multiFieldValue; ``` +#### Example usage with Scala: +```scala +import java.time.OffsetDateTime + +import org.frekele.elasticsearch.mapping.MappingBuilderImpl +import org.frekele.elasticsearch.mapping.annotations._ +import org.frekele.elasticsearch.mapping.annotations.values.IntValue + +import scala.annotation.meta.field + +case class BookEntity( + @(ElasticKeywordField@field) + isbn: String, + + @(ElasticTextField@field) + @(ElasticKeywordField@field)(ignoreAbove = new IntValue(256)) + @(ElasticCompletionField@field) + name: String, + + @(ElasticTextField@field) + description: String, + + @(ElasticDateField@field) + releaseDate: OffsetDateTime, + + @(ElasticBooleanField@field) + active: Boolean, + + @(ElasticBinaryField@field) + imageBlob: String, + + @(ElasticObjectField@field) + author: AuthorEntity + ) + +case class AuthorEntity( + @(ElasticLongField@field) + id: Long, + + @(ElasticTextField@field) + name: String, + + @(ElasticTextField@field) + @(ElasticKeywordField@field) + artisticName: String + ) + +object Main extends App { + println(new MappingBuilderImpl().build(true, classOf[BookEntity]).getContentAsString) +} +``` + ## License ``` Copyright © 2017-2019 - @frekele From 5f183ce762d3836f459ea9c454bd8b1e4f073d67 Mon Sep 17 00:00:00 2001 From: fbpi Date: Thu, 2 Apr 2020 12:33:18 +0200 Subject: [PATCH 14/14] reduce dependencies to org.elasticsearch:elasticsearch-x-content instead of org.elasticsearch:elasticsearch --- pom.xml | 4 ++-- .../org/frekele/elasticsearch/mapping/ObjectMapping.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 1eec035..1f1a007 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ github - 7.6.1 + 7.6.2 7.1.1 3.3.3 0.8.5 @@ -106,7 +106,7 @@ org.elasticsearch - elasticsearch + elasticsearch-x-content ${elasticsearch.version} diff --git a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java index 65f0f69..720e041 100644 --- a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java +++ b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java @@ -1,6 +1,5 @@ package org.frekele.elasticsearch.mapping; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -26,9 +25,8 @@ public XContentBuilder getContent() throws IOException { } public String getContentAsString() throws IOException { - //return this.getContent(). - String json = Strings.toString(mapping); - return json; + mapping.close(); + return mapping.getOutputStream().toString(); } }