我有两个这样的聚合查询
{
"size": 0,
"aggregations": {
"count": {
"terms": {
"field": "iaClaimChargeID",
"size": 100000
},
"aggs": {
"PaymentAmt": {
"sum": {
"field": "PaymentAmt"
}
},
"payment_amt_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"PaymentAmt": "PaymentAmt"
},
"script": "params.PaymentAmt !=0"
}
},
"duplicate": {
"top_hits": {
"sort": [
{
"PaymentDate": {
"order": "asc"
}
}
],
"size": 10
}
}
}
}
}
}
第二个-
{
"size": 0,
"aggs": {
"countsIaclaimchargeID": {
"terms": {
"field": "iaClaimChargeID",
"size": 1000
},
"aggs": {
"PaymentAmtcount": {
"terms": {
"field": "PaymentAmt"
}
}
}
}
}
}
在第一个查询中,我得到的是付款金额Amt和根据claimchargeID
的计数。
对于第二个,我得到了claimcharge
id的计数桶以及与它们相关的不同付款金额的计数。
如何将这两种聚合结合起来,以便获得
IaclaimchargeID
的数量ClaimchargeId
相关的付款金额IamclaimchargeID
相关的每个付款金额的计数。 如果我这样合并
{
"size": 0,
"aggs": {
"countsIaclaimchargeID": {
"terms": {
"field": "iaClaimChargeID",
"size": 1000
},
"aggs": {
"PaymentAmtcount": {
"terms": {
"field": "PaymentAmt"
},
"aggs": {
"PaymentAmt": {
"sum": {
"field": "PaymentAmt"
}
},
"payment_amt_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"PaymentAmt": "PaymentAmt"
},
"script": "params.PaymentAmt !=0"
}
},
"duplicate": {
"top_hits": {
"sort": [{
"PaymentDate": {
"order": "asc"
}
}],
"size": 10
}
}
}
}
}
}
}
}
然后我正在为PaymentAmt
空桶。