DATAES-148 - Dynamic mapping setting.

Original PR: #344
This commit is contained in:
Peter-Josef Meisch
2019-11-09 20:54:44 +01:00
committed by GitHub
parent 26ab706e87
commit 8bc133d955
4 changed files with 116 additions and 13 deletions

View File

@@ -514,6 +514,27 @@ public class MappingBuilderTests extends MappingContextBaseTests {
assertEquals(expected, mapping, true);
}
@Test
void shouldWriteDynamicMappingSettings() throws IOException, JSONException {
String expected = "{\n" + //
" \"dms\": {\n" + //
" \"dynamic\": \"false\",\n" + //
" \"properties\": {\n" + //
" \"author\": {\n" + //
" \"dynamic\": \"strict\",\n" + //
" \"type\": \"object\",\n" + //
" \"properties\": {}\n" + //
" }\n" + //
" }\n" + //
" }\n" + //
"}\n";
String mapping = getMappingBuilder().buildPropertyMapping(ConfigureDynamicMappingEntity.class);
assertEquals(expected, mapping, true);
}
/**
* @author Xiao Yu
*/
@@ -948,4 +969,19 @@ public class MappingBuilderTests extends MappingContextBaseTests {
@Field(termVector = TermVector.with_offsets) private String termVectorWithOffsets;
@Field(type = FieldType.Scaled_Float, scalingFactor = 100.0) Double scaledFloat;
}
@Document(indexName = "test-index-configure-dynamic-mapping", type = "dms")
@DynamicMapping(DynamicMappingValue.False)
static class ConfigureDynamicMappingEntity {
@DynamicMapping(DynamicMappingValue.Strict) @Field(type = FieldType.Object) private Author author;
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
}
}