0

Is there a way to filter out the _shards from the Elasticsearch query response?

I am looking for an option like size which removes the results from the hits, but for telling Elasticsearch that I don't need the _shards key.

An alternative would be to use jq to delete certain keys.

Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
  • 1
    This answer should help: https://stackoverflow.com/questions/33481977/elasticsearch-remove-default-fields-from-searchs-response-body/33482067#33482067 (hint: use `filter_path`) – Val May 26 '20 at 07:47
  • 2
    Indeed! I voted for a close as duplicate in this case. Thanks! – Gabriel Petrovay May 26 '20 at 08:05

1 Answers1

2

You can use filter_path

GET index84/_search?filter_path=-_shards

(note the - prefixing the _shards)

or, for example, if only the found items are needed:

GET index84/_search?filter_path=hits.hits
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
jaspreet chahal
  • 8,817
  • 2
  • 11
  • 29