santosh kumar
santosh kumar

Reputation: 341

Unknown key for a START_ARRAY in [fields]. in elasticsearch

I have been trying to get the specific fields data from the index that is been provided but getting the error "Unknown key for a START_ARRAY in [fields]".

Unknown key for a START_ARRAY in [fields].

fields: ['snippet.publishedAt']

my expected output out is it should provide the fields array in the hits

Upvotes: 23

Views: 23277

Answers (2)

Val
Val

Reputation: 217544

You should be using stored_fields or _source instead of fields, i.e.

stored_fields: ['snippet.publishedAt']

or

_source: ['snippet.publishedAt']

UPDATE:

From 7.10 onwards, a new fields features is now available.

Upvotes: 35

robvankeilegom
robvankeilegom

Reputation: 168

For ES7.3 (current version as writing) you can pass a _source field which can contain a comma separated list of fields.

_source: 'snippet.publishedAt'

You can read more about this here

Upvotes: 5

Related Questions