Order or Sort Serial_diff Agg result

I am trying to sort the result of a serial_diff agg. and struggling with that. Below is the code

ET db/_search
{
    "size": 0,
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "Name": [
                            "q"
                        ]
                    }
                }
            ],
            "filter": [
                {
                    "range": {
                        "ts": {
                            "gte": "2020-03-09T09:00:00.000Z",
                            "lte": "2020-03-09T12:40:00.000Z",
                            "format": "date_optional_time"
                        }
                    }
                }
            ]
        }
    },
    "aggs": {
        "sourceNameCount": {
            "cardinality": {
                "field": "sourceName"
            }
        },
        "sourceName": {
            "terms": {
                "size": 100,
                "field": "sourceName"
            },
            "aggs": {
                "timeseries": {
                    "date_histogram": {
                        "field": "ts",
                        "min_doc_count": 1,
                        "interval": "15m",
                        "order": {
                          "_key": "asc"
                        }

                    },
                    "aggs": {
                      "the_sum":{
                        "avg":{
                            "field": "libVal"
                        }
                      },
                      "ts_diff":{
                        "serial_diff": {
                          "buckets_path": "the_sum",
                          "lag": 1
                        }
                      }
                    }
                }
              }
          }
      }
  }

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