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 it 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 elastic#63709
  • Loading branch information
Christoph Büscher committed Feb 5, 2021
1 parent 094f24c commit 3073314
Show file tree
Hide file tree
Showing 23 changed files with 770 additions and 82 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 -> org.elasticsearch.common.collect.List.of();
return (lookup, ignoredFields) -> org.elasticsearch.common.collect.List.of();
}
return new DocValueFetcher(docValueFormat(format, null), context.getForField(this));
}
Expand Down
Loading

0 comments on commit 3073314

Please sign in to comment.