for (Entry<String, Object> subfield : fields.entrySet()) {
Map<String, Object> subFieldDef = (Map<String, Object>) subfield.getValue();
FieldType subFieldType = FieldType.parse(subFieldDef.get("type").toString());
if (defaultType != null) {
if (defaultType != subFieldType) {
throw new EsHadoopIllegalArgumentException(
String.format("Ambiguous mapping, multi_field [%s] provides no default field and subfields have different mapping types [%s=%s], [%s=%s]",
key, defaultFieldName, defaultType, subfield.getKey(), subFieldType));
}
}
else {
defaultFieldName = subfield.getKey();
defaultType = subFieldType;
}
}
}
else {
defaultType = FieldType.parse(defaultField.get("type").toString());
}
return new Field(key, defaultType);
}
if (FieldType.isRelevant(fieldType)) {
return new Field(key, fieldType);
}
else {
return null;
}
}
// no type - iterate through types
List<Field> fields = new ArrayList<Field>(content.size());
for (Entry<String, Object> e : content.entrySet()) {
if (e.getValue() instanceof Map) {
Field fl = parseField(e, key);
if (fl != null && fl.type == FieldType.OBJECT && "properties".equals(fl.name)) {
return new Field(key, fl.type, fl.properties);
}
if (fl != null) {
fields.add(fl);
}
}
}
return new Field(key, FieldType.OBJECT, fields);
}
throw new EsHadoopIllegalArgumentException("invalid map received " + entry);
}