Order results of date Histogram

Hello, is it possible to order the hourly aggregated values (results of a date histogram aggregation)? I wish to order the results based on the value instead of the date.

I think that I can not use a histogram aggregation because I still need the hourly/daily aggregation before I can order the values. To do so, I am trying this :
{
"query": {
....
},
"aggs": {
"datas": {
"date_histogram": {
"field": "@timestamp",
"interval": "1h"
},
"aggs": {
"OrderedValue":{
"terms":{"field":"value","order":{"ValueToOrder":"asc"}},
"aggs":{
"ValueToOrder": {"avg":{"field":"value"}
}
}
}
}
}
}
}

However, with this code, I can only order the values before the hourly aggregation...
And here is the format of my data
{
"_index": "metric-005215Troi",
"_type": "measured",
"_id": "005215Troi",
"_score": 4.3412647,
"_source": {
"name": "005215_Troi",
"@timestamp": "2017-09-23 23:00:00",
"value": 15.9
}
}

Can someone explain me how I can sort the results of a date histogram (ascending order of the value measured instead of the timestamp)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.