Skip to content

Commit

Permalink
apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Sep 25, 2018
1 parent 3635231 commit 235df36
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,22 @@ protected FieldCapabilitiesIndexResponse shardOperation(final FieldCapabilitiesI
continue;
}
// add nested and object fields
int dotIndex = ft.name().indexOf('.');
int dotIndex = ft.name().lastIndexOf('.');
while (dotIndex > -1) {
String parentField = ft.name().substring(0, dotIndex);
ObjectMapper mapper = mapperService.getObjectMapper(parentField);
if (mapper != null) {
if (responseMap.containsKey(parentField)) {
// we added this path on another field already
break;
}
// checks if the parent field contains sub-fields
if (mapperService.fullName(parentField) == null) {
// no field type, it must be an object field
ObjectMapper mapper = mapperService.getObjectMapper(parentField);
String type = mapper.nested().isNested() ? "nested" : "object";
FieldCapabilities fieldCap = new FieldCapabilities(parentField, type, false, false);
responseMap.put(parentField, fieldCap);
}
dotIndex = ft.name().indexOf('.', dotIndex + 1);
dotIndex = parentField.lastIndexOf('.');
}
}
}
Expand Down

0 comments on commit 235df36

Please sign in to comment.