use of org.opensearch.client.opensearch._types.mapping.TypeMapping in project opensearch-java by opensearch-project.
the class VariantsTest method testNestedTaggedUnionWithDefaultTag.
@Test
public void testNestedTaggedUnionWithDefaultTag() {
// Object fields don't really exist in ES and are based on a naming convention where field names
// are dot-separated paths. The hierarchy is rebuilt from these names and ES doesn't send back
// "type": "object" for object properties.
//
// Mappings are therefore a hierarchy of internally-tagged unions based on the "type" property
// with a default "object" tag value if the "type" property is missing.
String json = "{\n" + " \"testindex\" : {\n" + " \"mappings\" : {\n" + " \"properties\" : {\n" + " \"id\" : {\n" + " \"type\" : \"text\",\n" + " \"fields\" : {\n" + " \"keyword\" : {\n" + " \"type\" : \"keyword\",\n" + " \"ignore_above\" : 256\n" + " }\n" + " }\n" + " },\n" + " \"name\" : {\n" + " \"properties\" : {\n" + " \"first\" : {\n" + " \"type\" : \"text\",\n" + " \"fields\" : {\n" + " \"keyword\" : {\n" + " \"type\" : \"keyword\",\n" + " \"ignore_above\" : 256\n" + " }\n" + " }\n" + " },\n" + " \"last\" : {\n" + " \"type\" : \"text\",\n" + " \"fields\" : {\n" + " \"keyword\" : {\n" + " \"type\" : \"keyword\",\n" + " \"ignore_above\" : 256\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
GetMappingResponse response = fromJson(json, GetMappingResponse.class);
TypeMapping mappings = response.get("testindex").mappings();
assertTrue(mappings.properties().get("name").isObject());
assertEquals(256, mappings.properties().get("name").object().properties().get("first").text().fields().get("keyword").keyword().ignoreAbove().longValue());
assertTrue(mappings.properties().get("id").isText());
assertEquals(256, mappings.properties().get("id").text().fields().get("keyword").keyword().ignoreAbove().longValue());
}
Aggregations