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 filtering is not a scripting language, but really just allows you to include or exclude parts of the JSON document - no more, no less.
You could either use scripting on query time to return the number of children or just add a field during indexing that contains the number of children.
If you however want to execute searches on the children and only get back those children that matched, you should take a look at the inner_hits feature.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.