How to create buckets for number of occurances

I am needing to create a query that will show users that have uploaded 'x' number of receipts. I would like to have the receipt counts as defined 'buckets' which would range from, '0' to '10+'. I have tried to utilize the range aggregation but was unable to solve my issue.

The following query gives me the total number of users that submitted receipts, however my next step would be to group those users in the 'buckets' as listed above.


#Total Users that Submitted
GET /myreceiptindex/_search
{
"track_total_hits": true,
"size": 0,
"query": {
"bool": {
"must": [
{
"match": {
"moderationOutcome": "Successful"
}
},
{
"range": {
"uploadedOn": {
"lte": "2019-03-31T23:59:59+00:00",
"gt": "2019-02-01T12:00:00+00:00"
}
}
},
{
"range": {
"purchasedOn": {
"lte": "2019-03-31T23:59:59+00:00",
"gt": "2019-02-01T12:00:00+00:00"
}
}
}
]
}
},
"aggs": {
"users_that_submitted_receipts": {
"cardinality": {
"field": "participant.participantKey"
}
}
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.