# Stats aggregation of a date\_histogram

**URL:** https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731
**Category:** Elasticsearch
**Created:** [May 26, 2014, 6:45pm UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731 "2014-05-26T18:45:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)
#### Post date: [May 26, 2014, 6:45pm UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731/1 "2014-05-26T18:45:24Z")

</div>

Using ES 1.2

Is there a way to aggregate an aggregation?

So say I have a query for "views" per seconds for the last 5 minutes...

POST /xxx/xxx/\_search  
{  
"size": 0,  
"aggs": {  
"last\_5\_mins": {  
"filter": {  
"range": {  
"viewed": {  
"gte": "now-5m",  
"lte": "now"  
}  
}  
},  
"aggs": {  
"views\_per\_second": {  
"date\_histogram": {  
"field": "viewed",  
"interval": "second"  
}  
}  
}  
}  
}  
}

I would like to get my a stats aggregation of the date\_histogram.

So I would like to know what was my highest peek of views and my avg views  
per second.  
Is it possible or I have to do those calculations myself based on the  
aggregation returned?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [May 27, 2014, 10:39am UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731/2 "2014-05-27T10:39:18Z")

</div>

Aggregations cannot run on the data that they produce so this is something  
that you would need to do on client side for now.

On Mon, May 26, 2014 at 8:45 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com) wrote:

> Using ES 1.2
> 
> Is there a way to aggregate an aggregation?
> 
> So say I have a query for "views" per seconds for the last 5 minutes...
> 
> POST /xxx/xxx/\_search  
> {  
> "size": 0,  
> "aggs": {  
> "last\_5\_mins": {  
> "filter": {  
> "range": {  
> "viewed": {  
> "gte": "now-5m",  
> "lte": "now"  
> }  
> }  
> },  
> "aggs": {  
> "views\_per\_second": {  
> "date\_histogram": {  
> "field": "viewed",  
> "interval": "second"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> I would like to get my a stats aggregation of the date\_histogram.
> 
> So I would like to know what was my highest peek of views and my avg views  
> per second.  
> Is it possible or I have to do those calculations myself based on the  
> aggregation returned?
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d63a3edf-f9c6-4e40-9870-7b61e0e6a831%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7QNwyd\_5K5-3NuU%3DwWaey2XWntFckF9skBmBXSogUXbg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7QNwyd_5K5-3NuU%3DwWaey2XWntFckF9skBmBXSogUXbg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)
#### Post date: [May 27, 2014, 1:17pm UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731/3 "2014-05-27T13:17:47Z")

</div>

Thanks is this something planned?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b7a8b7d7-a7d0-4943-bacf-5014e4e7183f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b7a8b7d7-a7d0-4943-bacf-5014e4e7183f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [May 30, 2014, 6:06am UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731/4 "2014-05-30T06:06:39Z")

</div>

No concrete plans so far, but this is indeed a feature we are thinking of.

On Tue, May 27, 2014 at 3:17 PM, John Smith [java.dev.mtl@gmail.com](mailto:java.dev.mtl@gmail.com) wrote:

> Thanks is this something planned?
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/b7a8b7d7-a7d0-4943-bacf-5014e4e7183f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b7a8b7d7-a7d0-4943-bacf-5014e4e7183f%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7RyN6EzRawEgPQ%3DbQOpqyJtJBRJUP1EGQt2BcCFaa9FQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7RyN6EzRawEgPQ%3DbQOpqyJtJBRJUP1EGQt2BcCFaa9FQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:25am UTC](https://discuss.elastic.co/t/stats-aggregation-of-a-date-histogram/17731/5 "2017-07-06T01:25:57Z")

</div>


