# Pipeline aggregation \[Only sibling pipeline aggregations are allowed at the top level\]

**URL:** https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894
**Category:** Elasticsearch
**Created:** [November 30, 2015, 12:11pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894 "2015-11-30T12:11:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![vladmiller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladmiller/32/5909_2.png) [@vladmiller](https://discuss.elastic.co/u/vladmiller)
#### Post date: [November 30, 2015, 12:11pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894/1 "2015-11-30T12:11:07Z")

</div>

Hi friends,

I am trying to do some calculations over existing bucket. The goal is to generate average pageviews per session, therefore I first get the number of unique **sessions** , then I read number of unique **sessions** and last step I try to divide those two.

However, instead of desired result I see

> Invalid pipeline aggregation named [viewsPerSession] of type [bucket\_script]. Only sibling pipeline aggregations are allowed at the top level

I tried few different combinations of bucket selector however still no luck. Can someone please explain how to use pipeline aggregations?

Thanks

* * *

> POST /\_search  
> {  
> "size": 0,  
> "aggs": {  
> "pageviews": {  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "term": {  
> "action": "pageview"  
> }  
> },  
> {  
> "term": {  
> "payload.context": "reward"  
> }  
> }  
> ]  
> }  
> }  
> },  
> "sessions": {  
> "cardinality": {  
> "field": "sessionID"  
> }  
> },  
> "viewsPerSession": {  
> "bucket\_script": {  
> "buckets\_path": {  
> "pageviews": "pageviews",  
> "sessions": "sessions"  
> },  
> "script": "pageviews / sessions"  
> }  
> }  
> }  
> }

---

<div class="post-metadata">

### Author: ![Ele\_Jim](https://avatars.discourse-cdn.com/v4/letter/e/e274bd/32.png) [@Ele\_Jim](https://discuss.elastic.co/u/Ele_Jim)
#### Post date: [April 22, 2016, 2:59am UTC](https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894/2 "2016-04-22T02:59:32Z")

</div>

Hi. Did you find a solution to your problem?  
If so, do mind sharing it with me?  
I have similar problem, but yet no idea how to fix it.  
Thx

---

<div class="post-metadata">

### Author: ![Louis](https://avatars.discourse-cdn.com/v4/letter/l/ecb155/32.png) [@Louis](https://discuss.elastic.co/u/Louis)
#### Post date: [June 17, 2016, 6:59pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894/3 "2016-06-17T18:59:03Z")

</div>

I am also interested in using pipeline aggregations in Kibana

---

<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: [July 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/pipeline-aggregation-only-sibling-pipeline-aggregations-are-allowed-at-the-top-level/35894/4 "2017-07-05T22:42:41Z")

</div>


