Hi, I'm struggling how to apply a post_filter to some nested documents.
What I'd like to do is have some aggregation on all my nested documents, but have only certain nested documents returned (the general idea of a post_filter). I'm succesfull in applying the post_filter to filter out the root (parent)-documents, but not in filtering the inner hits on this document.
As an example, I've created two documents that each contain 2 people (with a name and age), and what I'd like to have returned is a) a histogram of their ages b) the people who are under 25.
The code as it is now succesfully filters the right document, but not only gives me Dave (age 20) in the inner_hits, but also Carlos (age 50), I think because he is in the document with Dave.
What I would like to see is the same as I would get with the range-query included in the nested query, but with the aggregation over all the documents.
Is this possible, or should I just work around it by using 2 seperate queries?
This was a bit of a headscratcher. I started to wonder if this was possible, but then because of this issue with a related pull request, I knew that it must be.
Then I stopped fixating on the path, and the various parameters available in the inner_hits object of the query, and it became clear.
Thanks, this was exactly what I was looking for!
As you wrote it down it seems perfectly logical to do it this way, yet I was scratching my head as well.
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.