Say I have a series of documents with an event type and a user_id. Is there an Elasticsearch pipeline aggregation that allows me to divide the count of events by the unique total users (not total users per event)? I know I can do this in timelion but trying to craft a query to do this. Any pointers?
Here is what I have so far:
{
"aggs": {
"event_count": {
"terms": {
"field": "event",
"size": 5,
"order": {
"_count": "desc"
}
}
},
"num_users": {
"cardinality": {
"field": "user_id"
}
}
},
"size": 0
}
I want to divide each of the event_count values by num_users. Is that possible? I've tried a bucket script aggregation but not sure how I would work the paths out.
Hope I have explained that clearly enough! Thanks