只想要 sumtotal 结果,不想要bookingIdGroup.buckets结果,但是它对我汇总sumtotal有作用。
GET /booking_order_list_v1/_search
{
"from": 0,
"size": 1,
"aggs": {
"bookingIdGroup": {
"terms": {
"field": "bookingId",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
},
"aggregations": {
"bookingTeuTotal": {
"sum": {
"field": "bookingTeu"
}
},
"supplementTeuTotal": {
"sum": {
"field": "supplementTeu"
}
},
"actualTeu": {
"bucket_script": {
"buckets_path": {
"supplementTeuTotal": "supplementTeuTotal",
"bookingTeuTotal": "bookingTeuTotal"
},
"script": {
"source": "params.bookingTeuTotal > params.supplementTeuTotal ? params.supplementTeuTotal : params.bookingTeuTotal",
"lang": "painless"
},
"gap_policy": "skip"
}
}
}
},
"sumtotal": {
"sum_bucket": {
"buckets_path": "bookingIdGroup.actualTeu"
}
}
}
}