Skip to content

Commit

Permalink
Return structured nested data in ‘fields’ API
Browse files Browse the repository at this point in the history
At the moment, the ‘fields’ API handles nested fields the same way I handles non-nested object arrays: it just returns them in a flat list. However, the relationship between nested fields is something we should try to preserve, since this is the main purpose of mapping something as “nested” instead of just using an object.

This PR changes this by returning grouped field values that are inside a nested object according to the nested object they initially appear in. Any further object structures inside a nested object are again returned as a flattened list. Fields inside nested fields don’t appear in the flattened response outside of the nested path any more. The grouping of fields inside nested objects is applied recursively if nested mappings are defined inside another nested mapping.

Closes #63709
  • Loading branch information
Christoph Büscher authored Feb 5, 2021
1 parent 366befc commit e2d5183
Show file tree
Hide file tree
Showing 23 changed files with 768 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static class TokenCountFieldType extends NumberFieldMapper.NumberFieldType {
@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
if (hasDocValues() == false) {
return lookup -> List.of();
return (lookup, ignoredFields) -> List.of();
}
return new DocValueFetcher(docValueFormat(format, null), context.getForField(this));
}
Expand Down
Loading

0 comments on commit e2d5183

Please sign in to comment.