Hi All,
I am trying to calculate the percentage in Elasticsearch using bucket script and below is the query I have tried it in kibana,
{
"size": 0,
"aggs": {
"Bits": {
"filters": {
"filters": {
"ItemBits": {
"match": {
"itemname": "bits"
}
}
}
},
"aggs": {
"value_max": {
"max": {
"field": "value"
}
}
}
},
"Speed": {
"filters": {
"filters": {
"ItemSpeed": {
"match": {
"itemname": "speed"
}
}
}
},
"aggs": {
"value_max": {
"max": {
"field": "value"
}
}
}
},
"Bandwidth-percentage": {
"bucket_script": {
"buckets_path": {
"TotalSpeed": "Speed>value_max",
"TotalBits": "Bits>value_max"
},
"script": "params.TotalSpeed / params.TotalBits * 100"
}
}
}
}
and I am getting the below error when I executed,
{
"error" : {
"root_cause" : [
{
"type" : "aggregation_execution_exception",
"reason" : "Invalid pipeline aggregation named [Bandwidth-percentage] of type [bucket_script]. Only sibling pipeline aggregations are allowed at the top level"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "getzabbixkpi",
"node" : "uyi22v7aR3i8MqdlxaX3jg",
"reason" : {
"type" : "aggregation_execution_exception",
"reason" : "Invalid pipeline aggregation named [Bandwidth-percentage] of type [bucket_script]. Only sibling pipeline aggregations are allowed at the top level"
}
}
]
},
"status" : 500
Please correct me If I am doing anything wrong.
Thanks,
Ganeshbabu R