Hi,
I have a basic code that provides the sum spent for all items in the following list
"query": {
"bool": {
"should": [
{ "match": { "description": "A" }}
, { "match": { "description": "B" }}
, { "match": { "description": "C" }}
, { "match": { "description": "D" }}
],
"minimum_should_match": 1,
"must": [
{ "range": { "transactiondate": { "gte": "2018-01-01" } } }
, { "range": { "moneyout": { "gt": 100 } } }
],
"must_not": {
"bool": {
"must": [
{ "match": { "transactiontype": "ATM Cash Withdrawal" } }
]
}
}
}
},
"aggs" : {
"total_spent" : {
"sum" : {
"field" : "moneyout",
"script" : {
"source": "_value"
}
}
}
}
}
Now this works fine and get to total sum for "moneyout" field for all matches..
However, I would like to get the sum for each match i.e. A and B and C and D in the above list plus the total sum. How can I achieve that?
Thanks,
Mich