I use Elasticsearch for my Search Service and I use this JSON request for sum_bucket aggregation:
"from": 0,
"size": 0,
"aggregations": {
"aggr": {
"type": "term",
"field": "type.keyword",
"size": 10,
"order": {
"myAggr2.value": "desc"
},
"aggregations": {
"myAggr2": {
"type": "sum",
"field": "length"
}
}
},
"total_myAggr2": {
"type": "sum_bucket",
"buckets_path": "aggr>myAggr2"
}
},
"types": [
"cable"
]
}
In the response I get this:
{
"totalHits": 4,
"tookInMillis": 1,
"hits": [],
"aggregations": {
"total_myAggr2": {
"value": "3.7600000000000002"
},
"aggr": {
"sumOtherDocCount": 0,
"buckets": [
{
"key": "cable",
"count": 4,
"aggregations": {
"myAggr2": {
"value": "3.7600000000000002"
}
}
}
]
}
}
}
Is any possibility to format the output from "3.7600000000000002"
to "3.76"
? I found attribute format in ES docu but not for number formatting...