Imagine I have three different types of data stored in my ElasticSearch
index: users, posts, and replies. Each post belongs to a particular user.
Each reply belongs to a particular user and post.
I'd like to write a query to find all users with a particular number of
posts (e.g., find all users with exactly one post, or all users with
between ten and twenty posts).
Along those same lines, I'd like to find all users with posts having a
particular number of replies. Basically, I'd like to filter documents based
on facet counts, which seems like a pretty reasonable thing to do, but I
can't figure out any way to do it.
I've tried to model this problem with embedded objects, nested objects, and
parent/child objects, but the query DSL doesn't seem to support these kinds
of queries, no matter how I model the data.
If you can denormalize, you should be able to do script filters (query or
aggregations, whichever you need). It's not gonna be the fastest thing in
the world but consider this example:
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.