Inside my document 'user' I have a field 'purchases' and my users have got a large amount of purchases. My problem is that I need to know which users have more than a certain number of purchases.
'purchases' is a nested field and inside all of them I've got a field called 'quantity' and I need to aggregate all of quantities of my users. That's how I'm trying to search them so far.
{
"query":{
"bool":{
"must":[
{
"nested":{
"path":"purchases",
"query":{
"bool":{
"should":[
{
"range":{
"purchases.quantity":{
"gte":"1",
"lte":"10"
}
}
}
],
"minimum_should_match":1
}
}
}
}
]
}
}
}