Hi,
I have an query that calculates average speed for different car makes based on the fields 'distance' and 'time' in travel documents in Elasticsearch:
POST /test_data/_search
{
"size": 0,
"aggs": {
"speed_per_make": {
"terms": {
"field": "CarMake"
},
"aggs": {
"sum_dist": {
"sum": {
"field": "DistanceCovered"
}
},
"sum_time": {
"sum": {
"field": "DrivingDurationHours"
}
},
"division": {
"bucket_script": {
"buckets_path": {
"var_sum_dist": "sum_dist",
"var_sum_time": "sum_time"
},
"script": "params.var_dist / params.var_time"
}
}
}
}
}
}
For each car make it sums the distance and time, and then calculates the speed.
How can I plot this in a vertical bar chart?
Thanks!