FieldMappings implements Mappings<Map<String, Object>> { public void flat(BiConsumer<String, String> func) { flatMappings(data(), Optional.empty(), func); } FieldMappings(MappingMetadata mappings);  FieldMappings(Map<String, Map<String, Object>> mapping); @Override boolean has(String path); @Override Map<String, Object> mapping(String path); @Override Map<String, Map<String, Object>> data(); void flat(BiConsumer<String, String> func); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void flatFieldMappingsShouldIncludeFieldsOnAllLevels() { IndexMappings indexMappings = LocalClusterState.state().getFieldMappings(new String[]{"field_mappings"}); FieldMappings fieldMappings = indexMappings.firstMapping().firstMapping(); Map<String, String> typeByFieldName = new HashMap<>(); fieldMappings.flat(typeByFieldName::put); assertThat( typeByFieldName, allOf( aMapWithSize(13), hasEntry("address", "text"), hasEntry("age", "integer"), hasEntry("employer", "text"), hasEntry("employer.raw", "text"), hasEntry("employer.keyword", "keyword"), hasEntry("projects", "nested"), hasEntry("projects.active", "boolean"), hasEntry("projects.members", "nested"), hasEntry("projects.members.name", "text"), hasEntry("manager", "object"), hasEntry("manager.name", "text"), hasEntry("manager.name.keyword", "keyword"), hasEntry("manager.address", "keyword") ) ); }