Skip to content

Support fetching flattened subfields #70605

@jtibshirani

Description

@jtibshirani

Currently we allow fetching the root flattened field through "fields": ["flattened_field"]. We should also allow fetching its subfields. For example, specifying "fields": ["flattened_field.subfield1"] would return a response like this:

"fields": [{
  "flattened_field.subfield1": ["value1"]
}]

We allow flattened subfields to be used in queries, aggregations, and even docvalue_fields, so this enhancement would make sure the fields option behaves consistently. These subfields would only be returned when they're explicitly requested. This follows the same behavior as other parts of the search API, where field wildcard patterns only match against the root flattened field and not its subfields (which aren't technically in the mapping).

Note that if you retrieve both the root flattened field and a subfield, the response might contain the same data twice. This could be a little surprising, but seems like okay behavior to me. For example, "fields": ["flattened_field", "flattened_field.subfield1"] might return the following:

"fields": [{
  "flattened_field": [{
    "subfield1": "value1",
    "subfield2": "value2"
  }],
  "flattened_field.subfield1": ["value1"]
}]

Metadata

Metadata

Assignees

Labels

:Search/SearchSearch-related issues that do not fall into other categories>enhancementTeam:SearchMeta label for search team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions