Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter _source before it is returned back from API?

I have many field in _source of indexed document. However I don't need all of them to be returned form search query. For now for each found document the whole _source is returned. How I can force to receive only specific fields of each _source?

like image 504
user606521 Avatar asked Mar 18 '23 22:03

user606521


1 Answers

So to answer your answer in general,

For version < 1

use (in search request)

{
   "fields" : ["fields you want to get"]
}

so response contains fields, not source

if version > = 1 then,

you can use

{
   "_source":[ "fields to include"]
}

source filtering can be found here .

Hope this helps.

like image 190
progrrammer Avatar answered Apr 06 '23 15:04

progrrammer