Search query to retrieve nested documents in elasticsearch with _source disabled
If you use Source Filtering it will return the nested objects as a whole, your query would be:
{ "_source": [ "name", "variation" ], "query": { "nested": { "path": "variation", "query": { "bool": { "must": [ { "term": { "variation.size": "XXL" } }, { "term": { "variation.color": "red" } } ] } } } }}
You should use this:
"script_fields": {"variation": { "script": { "inline": "doc['variation.size'].value + ' ' + doc['variation.red'].value" } }}
I use elasticsearch v. 5.1.1