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

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"
}
}
}
}

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

1 Like

I am also interested in using pipeline aggregations in Kibana