I want to manually specify terms to group in aggregations i have a query like this
{
"index": "xxx-xxx",
"size": 0,
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"referralId": "1234567890ertyui"
}
},
{
"match": {
"transactionType.keyword": "TRANSFER"
}
}
]
}
},
"sort": {
"timeCreated": {
"order": "desc"
}
},
"aggs": {
"transfer_metrics": {
"terms": {
"field": "recipientBank.keyword"
},
"aggs": {
"value": {
"sum": {
"field": "amount"
}
},
"volume": {
"terms": {
"field": "transactionStatus.keyword"
}
}
}
}
}
}
}
i get an aggregagtion like this, i am only posting the aggregation part.
"aggregations": {
"transfer_metrics": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "GTBank",
"doc_count": 39,
"volume": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "BILL PURCHASED FAILED",
"doc_count": 29
},
{
"key": "PAYMENT FAILED",
"doc_count": 10
}
]
},
"value": {
"value": 13815
}
},
{
"key": "GTB",
"doc_count": 29,
"volume": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "BILL PURCHASED FAILED",
"doc_count": 15
},
{
"key": "PAYMENT FAILED",
"doc_count": 13
},
{
"key": "PAYMENT SUCCESSFUL",
"doc_count": 1
}
]
},
"value": {
"value": 442097
}
},
{
"key": "Gtb",
"doc_count": 11,
"volume": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "BILL PURCHASED FAILED",
"doc_count": 10
},
{
"key": "PAYMENT FAILED",
"doc_count": 1
}
]
},
"value": {
"value": 6720
}
},
{
"key": "United Bank for Africa",
"doc_count": 2,
"volume": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "BILL PURCHASED FAILED",
"doc_count": 2
}
]
},
"value": {
"value": 100
}
},
{
"key": "Access Bank",
"doc_count": 1,
"volume": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "BILL PURCHASED FAILED",
"doc_count": 1
}
]
},
"value": {
"value": 150
}
}
]
}
}
How do i tell Elasticsearch to group GTBank
, GTB
and Gtb
together and probably return it under a key of a specified key of like GT Bank
. And can I do it for multiple recipientBank
in one query, e.g inclusive of the above i add... group FB
, Fb
and First Bank
?