I have documents with parent-child relationship in Elasticsearch . When I do hasParentQuery or hasChildQuery , I need to know if a type of an index has parent-child relationship. Is it possible to achieve that, using Java client?
GetMappingsRequest getRequest = new GetMappingsRequest().indices("indexname");
GetMappingsResponse cs = client.admin().indices().getMappings(getRequest).get();
ImmutableOpenMap<String, MappingMetaData> mappingStr = cs.mappings().get("indexname");
for (ObjectObjectCursor<String, MappingMetaData> c : mappingStr) {
Map m = (Map) c.value.getSourceAsMap().get("_parent");
if (m != null) {
if (typeName.equals(m.get("type")))
types.add(c.key);
}
}
if(types.size>0){
return true;
}else{
return false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.