In other words, I think it would be very useful if we could nest metric 
aggregations, so a very straight syntax for the use case I described would 
be:

GET channel/Subscription/_search
{
  "size": 1, 
  "aggs": {
    "AvgSubsPerUser": {
      "avg": { "field": "$SubscriptionsPerUser.doc_count" },
     "aggs": {
       "SubscriptionsPerUser": {
         "terms": {
           "field": "UserId",
           "min_doc_count": 0,
           "size": 1000
         }
      }
    }
  }
  }
}
 

On Thursday, June 26, 2014 2:10:38 PM UTC-3, Demetrius Nunes wrote:
>
> Hi there,
>
> Is there a way to calculate the average over the doc_count result of a 
> bucket aggregation?
>
> For instance, I have this aggregation query:
>
> GET channel/Subscription/_search
> {
>   "size": 1, 
>   "aggs": {
>     "SubscriptionsPerUser": {
>       "terms": {
>         "field": "UserId",
>         "min_doc_count": 0,
>         "size": 1000
>       }
>     }
>   }
> }
>
> I would like to calculate the average doc_count for each resulting bucket, 
> which would give me the average subscriptions/user metric.
>
> Thanks,
> Demetrius
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/f58c358a-c70f-49c7-a80c-624767e2674b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to