Skip to content

Finalize how search 'fields' option returns nested data. #63709

@jtibshirani

Description

@jtibshirani

Currently the 'fields' option has no special handling for nested fields -- it just returns them in a flat list (as it does for a non-nested object array):

"fields": {
  "products.base_price": [43.99, 20.99],
  "products.manufacturer": ["Microlutions", "Elitelligence"],
  "products.product_id": [17426, 19288]
}

This drops the relationship between nested fields and could be misleading about the search behavior. Instead we could return an object array, where each entry contains the fields for a nested document:

"fields": {
  "products": [{
    "base_price": [43.99],
    "manufacturer": ["Microlutions"],
    "product_id": [17426],
  },
  {
    "base_price": [20.99],
    "manufacturer": ["Elitelligence"],
    "product_id": [19288],
  }]
}

Yet another option would be to not return any nested data when requesting 'fields' for the root doc, to match the behavior for docvalue_fields. Nested fields would only be available when using the inner_hits option. This is simple to implement but feels lacking: our users are familiar with _source filtering, which allows for accessing nested objects at the root level.

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