Serial_diff in query get error Only sibling pipeline aggregations are allowed at the top level

Hi,

I'm trying to calculate a serial difference between 2 values in different documents that are related by a project name and a "voie" fields (first part of the query).

Here is where i am :

{
  "query": {
    "bool": {
      "must": [
        { "match": { "nomProjet": "myProject2"} },
        { "match": { "voie": "3"} }
      ]
    }
  },
  "aggs": {
    "temp": {
      "histogram": {
        "field": "timePaquet",
        "interval": "0.1"
      },
      "aggs": {
        "monthly": {
          "sum": {
            "field": "mean"
          }
        }
      }
    },
    "sum_bucket_demo": {
      "serial_diff": {
        "buckets_path": "temp>monthly",
        "lag": 1
      }
    }
  }
}

As you can see, I don't have a timestamp field but I do have a ascendant numeric value (timePaquet). that's why I use a histogram instead of a date_histogram.

After a lot of comparisons with the documentation for serial_diff in elastic, I can't find my mistake.

The current error reason is : "Invalid pipeline aggregation named [sum_bucket_demo] of type [serial_diff]. Only sibling pipeline aggregations are allowed at the top level"

note : it's actually working with the sum_bucket aggregation.

Any advice would be much appreciated :slight_smile:

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