String[] parts = part.split("\\.", 2);
Object o = root.get(parts[0]);
if (o == null) {
o = new HashMap<String, Object>();
} else if (!(o instanceof Map)) {
throw new ElasticSearchException("Error on rewriting objects: Mixed objects and values");
}
Map<String, Object> sub = (Map<String, Object>) o;
writeMap(sub, value, parts[1]);
root.put(parts[0], sub);
} else {
if (((Map<String, Object>) root).get(part) instanceof Map) {
throw new ElasticSearchException("Error on rewriting objects: Mixed objects and values");
}
root.put(part, value);
}
}