I have an index full of documents. Each of them has a key "userid" with a distinct value per user, but each user may have multiple documents. Each user has additional properties (like "color", "animal").
I need to get the agg counts per property which would be:
aggs: {
colors: { terms: { field: color } },
animals: { terms: { field: animal } }
}
But I need these counts per unique userid, maybe:
aggs: {
group-by: { field: userid },
sub-aggs: {
colors: { terms: { field: color } },
animals: { terms: { field: animal } }
}
}
I looked at the nested aggregations, but didn't get it if they'd be helpful.
Is this possible?