diff --git a/README.md b/README.md
index ea00433..f1cbd3e 100644
--- a/README.md
+++ b/README.md
@@ -8,13 +8,14 @@
[](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/current/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html)
#### Compatibility:
-| Elasticsearch Mapping Builder | Elasticsearch |
-| ------------------------------| ---------------------- |
-| Version: 1.0.7 | Version: 5.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:
@@ -22,13 +23,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
@@ -60,7 +61,6 @@ public String getMapping() {
```
```java
-@ElasticDocument("book")
public class BookEntity {
@ElasticKeywordField
@@ -89,7 +89,6 @@ public class BookEntity {
.........
}
-@ElasticDocument(value = "author")
public class AuthorEntity {
@ElasticLongField
@@ -106,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();
}
```
@@ -133,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
@@ -177,26 +150,6 @@ public class EmployeeEntity {
#### Annotations parameters:
-###### ElasticDocument
-```java
-@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 MyDocumentEntity {
- .........
-```
-
-
###### ElasticBinaryField
```java
@ElasticBinaryField(
@@ -212,7 +165,6 @@ private String binaryValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true))
private Boolean booleanValue;
```
@@ -225,9 +177,7 @@ private Boolean booleanValue;
boost = @FloatValue(0.2f),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Byte byteValue;
@@ -255,7 +205,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)
@@ -272,7 +221,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)
@@ -288,9 +236,7 @@ private Date dateRangeValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Double doubleValue;
@@ -302,7 +248,6 @@ private Double doubleValue;
suffixName = "doubleRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -317,9 +262,7 @@ private Double doubleRangeValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Float floatValue;
@@ -331,7 +274,6 @@ private Float floatValue;
suffixName = "floatRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -370,9 +312,7 @@ private String geoShapeValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Float halfFloatValue;
@@ -386,9 +326,7 @@ private Float halfFloatValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Integer integerValue;
@@ -400,7 +338,6 @@ private Integer integerValue;
suffixName = "integerRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -413,7 +350,6 @@ private Integer integerRangeValue;
suffixName = "ip",
boost = @FloatValue(1),
docValues = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
nullValue = "NULL",
store = @BoolValue(true)
@@ -427,7 +363,6 @@ private String ipValue;
suffixName = "ipRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -443,7 +378,6 @@ private String ipRangeValue;
docValues = @BoolValue(true),
eagerGlobalOrdinals = @BoolValue(true),
ignoreAbove = @IntValue(350),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "docs",
norms = @BoolValue(true),
@@ -463,9 +397,7 @@ private String keywordValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Long longValue;
@@ -477,7 +409,6 @@ private Long longValue;
suffixName = "longRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -500,9 +431,7 @@ private String percolatorValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true),
scalingFactor = @IntValue(100)
)
@@ -517,9 +446,7 @@ private Float scaledFloatValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Short shortValue;
@@ -538,7 +465,6 @@ private Short shortValue;
max = @FloatValue(0.1f),
minSegmentSize = @IntValue(500)
),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "",
norms = @BoolValue(true),
@@ -562,7 +488,6 @@ private String textValue;
boost = @FloatValue(1),
docValues = @BoolValue(true),
index = @BoolValue(true),
- includeInAll = @BoolValue(true),
nullValue = "NULL",
store = @BoolValue(true)
)
@@ -609,7 +534,6 @@ private String customValue;
max = @FloatValue(0.1f),
minSegmentSize = @IntValue(500)
),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "",
norms = @BoolValue(true),
@@ -628,7 +552,6 @@ private String customValue;
docValues = @BoolValue(true),
eagerGlobalOrdinals = @BoolValue(true),
ignoreAbove = @IntValue(350),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "docs",
norms = @BoolValue(true),
@@ -648,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
diff --git a/pom.xml b/pom.xml
index ee07e51..1f1a007 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
@@ -87,10 +87,10 @@
github
- 5.6.16
- 6.14.3
- 2.25.1
- 0.8.3
+ 7.6.2
+ 7.1.1
+ 3.3.3
+ 0.8.5
3.8.0
3.1.1
@@ -106,7 +106,7 @@
org.elasticsearch
- elasticsearch
+ elasticsearch-x-content
${elasticsearch.version}
@@ -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/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..5d5a04f 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;
@@ -52,7 +24,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 +37,7 @@ public class MappingBuilderImpl implements MappingBuilder {
private int MAX_RECURSIVE_LEVEL = 50;
- private List docsClass;
+ private Class docsClass;
private XContentBuilder mapping;
@@ -74,18 +45,17 @@ 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 {
XContentBuilder xContentBuilder = this.innerBuild(pretty);
return new ObjectMapping(xContentBuilder);
@@ -94,7 +64,7 @@ public ObjectMapping build(boolean pretty, Class... documentClass) {
}
}
- public List getDocsClass() {
+ public Class getDocClass() {
return docsClass;
}
@@ -106,18 +76,6 @@ private void setMapping(XContentBuilder mapping) {
this.mapping = mapping;
}
- public static boolean isElasticDocument(Class documentClass) {
- return (documentClass.isAnnotationPresent(ElasticDocument.class));
- }
-
- public void validateElasticDocument() {
- for (Class clazz : this.getDocsClass()) {
- if (!isElasticDocument(clazz)) {
- throw new InvalidDocumentClassException("Document Class[" + clazz.getCanonicalName() + "] Invalid. @ElasticDocument must be present.");
- }
- }
- }
-
public static List getElasticFieldAnnotations(Field field) {
List result = new ArrayList<>();
Annotation[] annotations = field.getDeclaredAnnotations();
@@ -294,9 +252,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);
@@ -345,10 +300,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);
}
@@ -485,7 +436,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());
@@ -507,7 +457,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());
@@ -525,9 +474,7 @@ 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());
this.scalingFactor(vo.getScalingFactor());
this.closeSuffixName(subField);
@@ -535,63 +482,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.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), null);
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ 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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store(), elasticField.scalingFactor());
+ elasticField.boost(), elasticField.docValues(), elasticField.ignoreMalformed(),
+ elasticField.index(), 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);
}
@@ -602,7 +549,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);
}
@@ -620,7 +566,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);
@@ -628,31 +573,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);
}
@@ -664,7 +609,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());
@@ -673,8 +617,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.includeInAll(),
- elasticField.index(), elasticField.nullValue(), elasticField.store());
+ null, elasticField.format(), elasticField.locale(), null,
+ elasticField.index(), null, elasticField.store());
this.processElasticField(vo, subField);
}
@@ -703,7 +647,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());
@@ -729,7 +672,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);
@@ -789,21 +731,19 @@ 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.
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);
}
//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 +779,9 @@ 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());
+ Field[] fields = this.getDocClass().getDeclaredFields();
+ this.recursiveFields(fields, 0);
- //_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());
- }
- 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();
- }
-
- this.dynamic(elasticDocument.dynamic());
- this.includeInAll(elasticDocument.includeInAll());
-
- Field[] fields = clazz.getDeclaredFields();
- this.recursiveFields(fields, 0);
-
- //ElasticDocument
- this.getMapping().endObject();
- }
//mappings
this.getMapping().endObject();
//END
diff --git a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java
index 3449104..720e041 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/ObjectMapping.java
@@ -25,7 +25,8 @@ public XContentBuilder getContent() throws IOException {
}
public String getContentAsString() throws IOException {
- return this.getContent().string();
+ mapping.close();
+ return mapping.getOutputStream().toString();
}
}
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 6fded6f..f78b240 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticByteField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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..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,20 +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 includeInAll() 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/ElasticDocument.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java
deleted file mode 100644
index 99aead1..0000000
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDocument.java
+++ /dev/null
@@ -1,39 +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);
-
- BoolValue includeInAll() default @BoolValue(ignore = true);
-
- String parent() default "";
-
- //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..4b99b71 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticDoubleField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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..bac2a9f 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticFloatField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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/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/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java
index 63e790a..df7feb3 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticHalfFloatField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/ElasticIntegerField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java
index 8b8ef36..26a09f2 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticIntegerField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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..a39951b 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticLongField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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 0759b83..ca58bd6 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticScaledFloatField.java
@@ -33,14 +33,10 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() default @BoolValue(ignore = true);
-
BoolValue index() default @BoolValue(ignore = true);
- String nullValue() default "";
-
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/ElasticShortField.java b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java
index e9d8820..5ca0d0d 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/annotations/ElasticShortField.java
@@ -32,12 +32,8 @@
BoolValue ignoreMalformed() default @BoolValue(ignore = true);
- BoolValue includeInAll() 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/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 cd7272c..2071a80 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);
@@ -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..241fc22 100644
--- a/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java
+++ b/src/main/java/org/frekele/elasticsearch/mapping/values/NumericFieldValue.java
@@ -22,28 +22,22 @@ public class NumericFieldValue {
private BoolValue ignoreMalformed;
- private BoolValue includeInAll;
-
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 includeInAll,
- BoolValue index, String nullValue, BoolValue store, IntValue scalingFactor) {
+ BoolValue docValues, BoolValue ignoreMalformed,
+ BoolValue index, BoolValue store, IntValue scalingFactor) {
this.type = type;
this.suffixName = suffixName;
this.coerce = coerce;
this.boost = boost;
this.docValues = docValues;
this.ignoreMalformed = ignoreMalformed;
- this.includeInAll = includeInAll;
this.index = index;
- this.nullValue = nullValue;
this.store = store;
this.scalingFactor = scalingFactor;
}
@@ -72,18 +66,10 @@ public BoolValue getIgnoreMalformed() {
return ignoreMalformed;
}
- public BoolValue getIncludeInAll() {
- return includeInAll;
- }
-
public BoolValue getIndex() {
return index;
}
- public String getNullValue() {
- return nullValue;
- }
-
public BoolValue getStore() {
return store;
}
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/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..ae3dbc8 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\":{\"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..24921b3 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
@@ -30,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();
- mappingBuilder.validateElasticDocument();
- }
-
@Test(expectedExceptions = InvalidCustomJsonException.class)
public void buildWithErrorElasticCustomJsonFieldTest() throws Exception {
MappingBuilder mappingBuilder = new MappingBuilderImpl();
@@ -74,34 +39,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\",\"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);
+ 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,\"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);
+ 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/FullDocumentEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentEntity.java
index 557fa6b..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;
@@ -29,10 +28,10 @@
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;
-@ElasticDocument("full")
public class FullDocumentEntity {
@ElasticBinaryField
@@ -98,7 +97,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/FullDocumentTwoEntity.java b/src/test/java/org/frekele/elasticsearch/mapping/entities/generic/FullDocumentTwoEntity.java
index b108d8a..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(
@@ -49,7 +47,6 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true))
private Boolean booleanValue;
@@ -59,17 +56,15 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(0.2f),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Byte byteValue;
@ElasticCompletionField(
suffixName = "completion",
- analyzer = "myAnalyzer",
- searchAnalyzer = "mySearchAnalyzer",
+ analyzer = "standard",
+ searchAnalyzer = "standard",
preserveSeparators = @BoolValue(true),
preservePositionIncrements = @BoolValue(true),
maxInputLength = @IntValue(50)
@@ -83,7 +78,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)
@@ -93,13 +87,9 @@ public class FullDocumentTwoEntity {
@ElasticDateRangeField(
suffixName = "dateRange",
boost = @FloatValue(1),
- docValues = @BoolValue(true),
format = "basic_date_time",
locale = "en-US",
- ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Date dateRangeValue;
@@ -110,9 +100,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Double doubleValue;
@@ -121,7 +109,6 @@ public class FullDocumentTwoEntity {
suffixName = "doubleRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -133,9 +120,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Float floatValue;
@@ -144,7 +129,6 @@ public class FullDocumentTwoEntity {
suffixName = "floatRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -159,8 +143,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",
@@ -174,9 +158,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Float halfFloatValue;
@@ -187,9 +169,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Integer integerValue;
@@ -198,7 +178,6 @@ public class FullDocumentTwoEntity {
suffixName = "integerRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -208,9 +187,7 @@ public class FullDocumentTwoEntity {
suffixName = "ip",
boost = @FloatValue(1),
docValues = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private String ipValue;
@@ -219,7 +196,6 @@ public class FullDocumentTwoEntity {
suffixName = "ipRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -227,19 +203,16 @@ public class FullDocumentTwoEntity {
@ElasticKeywordField(
suffixName = "keyword",
- analyzer = "myAnalyzer",
boost = @FloatValue(1),
docValues = @BoolValue(true),
eagerGlobalOrdinals = @BoolValue(true),
ignoreAbove = @IntValue(350),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "docs",
norms = @BoolValue(true),
nullValue = "NULL",
store = @BoolValue(true),
- similarity = "BM25",
- normalizer = "my_normalizer"
+ similarity = "BM25"
)
private String keywordValue;
@@ -249,9 +222,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Long longValue;
@@ -260,7 +231,6 @@ public class FullDocumentTwoEntity {
suffixName = "longRange",
coerce = @BoolValue(true),
boost = @FloatValue(1),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
store = @BoolValue(true)
)
@@ -277,9 +247,7 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true),
scalingFactor = @IntValue(100)
)
@@ -291,16 +259,14 @@ public class FullDocumentTwoEntity {
boost = @FloatValue(1),
docValues = @BoolValue(true),
ignoreMalformed = @BoolValue(true),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
private Short shortValue;
@ElasticTextField(
suffixName = "text",
- analyzer = "myAnalyzer",
+ analyzer = "standard",
boost = @FloatValue(1),
eagerGlobalOrdinals = @BoolValue(true),
fielddata = @BoolValue(true),
@@ -309,14 +275,13 @@ public class FullDocumentTwoEntity {
max = @FloatValue(0.1f),
minSegmentSize = @IntValue(500)
),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "",
norms = @BoolValue(true),
positionIncrementGap = @IntValue(100),
store = @BoolValue(true),
- searchAnalyzer = "mySearchAnalyzer",
- searchQuoteAnalyzer = "my_analyzer",
+ searchAnalyzer = "standard",
+ searchQuoteAnalyzer = "standard",
similarity = "BM25",
termVector = "no",
copyTo = {"anotherField"}
@@ -325,27 +290,23 @@ public class FullDocumentTwoEntity {
@ElasticTokenCountField(
suffixName = "tokenCount",
- analyzer = "myAnalyzer",
+ analyzer = "standard",
enablePositionIncrements = @BoolValue(true),
boost = @FloatValue(1),
docValues = @BoolValue(true),
index = @BoolValue(true),
- includeInAll = @BoolValue(true),
- nullValue = "NULL",
store = @BoolValue(true)
)
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;
@@ -356,7 +317,7 @@ public class FullDocumentTwoEntity {
@ElasticTextField(
suffixName = "text",
- analyzer = "myAnalyzer",
+ analyzer = "standard",
boost = @FloatValue(1),
eagerGlobalOrdinals = @BoolValue(true),
fielddata = @BoolValue(true),
@@ -365,38 +326,34 @@ public class FullDocumentTwoEntity {
max = @FloatValue(0.1f),
minSegmentSize = @IntValue(500)
),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "",
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),
ignoreAbove = @IntValue(350),
- includeInAll = @BoolValue(true),
index = @BoolValue(true),
indexOptions = "docs",
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)
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/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
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/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 ab18e32..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
@@ -1,16 +1,15 @@
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;
-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;
-import java.time.OffsetDateTime;
-
-@ElasticDocument("book")
public class BookEntity {
@ElasticKeywordField
@@ -32,7 +31,7 @@ public class BookEntity {
@ElasticBinaryField
private String imageBlob;
- @ElasticObjectField
+ @ElasticObjectField(enabledJson = @BoolValue(false))
private AuthorEntity author;
public BookEntity() {
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..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", parent = "person")
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