I have an index with documents like this:
{ "firstName": "Fred", "lastName": "Flinstone", "children": [ { "firstName": "Pebbles", "lastName": "Flinstone", "age": 1 } ] }
When I do my search query, I want to get back just 3 fields: firstName, lastName and then the number of children. I am currently using Elasticsearch 5 and source filtering to include the firstName and lastName. The first two fields are not a problem, but how do I get a count of the nested children object to be returned?
In the end, I want my search result hits _source to be something like this:
"_source": { "firstName": "Fred", "lastName": "Flinstone", "numberOfChildren": 1 }