Hi, I have a use case and I am not sure how to accomplish it. I am doing a terms aggregation and as a result of it, I am getting list of buckets with each bucket having the doc_count
value. Is there anyway by which I can select a subset of those buckets which matches a certain condition based on the value of doc_count
?
Example:
Following is a sample mapping structure:
{ "mappings":{ "events":{ "properties":{ "name":{ "type":"string"}, "location":{ "type":"string"}, "user_id":{ "type":"string"} } } } }
My requirement is to get the list of users who have done a specific event atleast n number of times.
I am doing a filter on the event name and then grouping by user_id. This gives me the number of times each user has done this action. Now I want to filter this result where I want to select the users who have atleast 10 entires.
Note: atleast in the above query is just an example. I need to support atmost and other forms. So Ideally I need to select the buckets based on a predicate.