DATAES-211 - enhance multi field support as multifield type is removed

This commit is contained in:
Mohsin Husen
2016-02-10 16:21:29 +00:00
parent 09455006ab
commit 61880671a4
4 changed files with 10 additions and 10 deletions

View File

@@ -25,9 +25,9 @@ import java.lang.annotation.Target;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface NestedField {
public @interface InnerField {
String dotSuffix();
String suffix();
FieldType type();

View File

@@ -30,5 +30,5 @@ public @interface MultiField {
public Field mainField();
public NestedField[] otherFields() default {};
public InnerField[] otherFields() default {};
}

View File

@@ -268,8 +268,8 @@ class MappingBuilder {
* @throws IOException
*/
private static void addNestedFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
NestedField annotation) throws IOException {
builder.startObject(field.getName() + "." + annotation.dotSuffix());
InnerField annotation) throws IOException {
builder.startObject(annotation.suffix());
//builder.field(FIELD_STORE, annotation.store());
if (FieldType.Auto != annotation.type()) {
builder.field(FIELD_TYPE, annotation.type().name().toLowerCase());
@@ -298,8 +298,8 @@ class MappingBuilder {
builder.startObject("fields");
//add standard field
addSingleFieldMapping(builder, field, annotation.mainField(),nestedOrObjectField);
for (NestedField nestedField : annotation.otherFields()) {
addNestedFieldMapping(builder, field, nestedField);
for (InnerField innerField : annotation.otherFields()) {
addNestedFieldMapping(builder, field, innerField);
}
builder.endObject();
builder.endObject();