# Serial\_diff in query get error Only sibling pipeline aggregations are allowed at the top level

**URL:** <https://discuss.elastic.co/t/serial-diff-in-query-get-error-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/173950>\
**Category:** Elasticsearch\
**Created:** [March 26, 2019, 2:49pm UTC](https://discuss.elastic.co/t/serial-diff-in-query-get-error-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/173950 "2019-03-26T14:49:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stevens\_Laurent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevens_laurent/32/42789_2.png) [@Stevens\_Laurent](https://discuss.elastic.co/u/Stevens_Laurent)\
**Post date:** [March 26, 2019, 2:49pm UTC](https://discuss.elastic.co/t/serial-diff-in-query-get-error-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/173950/1 "2019-03-26T14:49:17Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 23, 2019, 2:49pm UTC](https://discuss.elastic.co/t/serial-diff-in-query-get-error-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/173950/2 "2019-04-23T14:49:17Z")

</div>

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