我想用一个bucket脚本在java中设置aggregationbuilders来计算查询中2个值的比率。
{
"aggs": {
"filt": {
"filters": {
"filters": {
"filter_aggs": {
"bool": {
"must": [
{
"match": {
"code": "A01/B6"
}
}
]
}
}
}
},
"aggs": {
"year20": {
"terms": {
"field": { "year20_count"}
}
},
"year5": {
"terms": {
"field": { "year5_count"}
}
},
"conc_percentage": {
"bucket_script": {
"buckets_path": {
"y20": "year20",
"y5": "year5"
},
"script": "(y5 / y20) * 100"
}
}
}
}
}
请求是这样设置的,但是如何过滤聚合并将2个同级聚合转换成bucket脚本到java代码呢?
暂无答案!
目前还没有任何答案,快来回答吧!