Skip to content

[Data Services] Support fields parameter in high level search apis #77241

@stacey-gammon

Description

@stacey-gammon

Many developers currently access field values directly from _source (this object is accessible in each hit from the hits array in a search request response). This exposes the raw source fields, which is often not actually what is desired. What is often desired is the mapped field values. This subtle difference leads to issues like this and this.

Recently Elasticsearch has recently exposed a way to access these mapped field values.

The data search services needs to provide a way for developers to use this new search parameter, in order to solve problems like runtime field values showing up blank in discover.

There are some differences in values retrieved from _source vs the fields array:

_source fields array
Includes alias fields No Yes
Includes runtime fields No Yes
Objects are flattened No Yes
Nested fields are flattened No Yes

There are performance considerations as well. If a searcher wants to get values for certain fields, maybe they want to turn _source off.

The bare minimum we'll need is the ability to allow users to define the list of fields returned in the fields array. Unfortunately an initial investigation revealed that it may not be straightforward to create a good DX, given that searchSource.fields(..) is already used for something else.

Additional possibilities that probably don't need to be included in the initial API:

  • ability for users to turn off _source to improve performance
  • ability for users to configure flattening (not yet exposed in ES but could be if desired).

Metadata

Metadata

Assignees

Labels

Feature:SearchQuerying infrastructure in KibanaProject:FieldsAccess field values from fields response, not sourceProject:RuntimeFieldsimpact:highAddressing this issue will have a high level of impact on the quality/strength of our product.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions