# Combining date\_histogram with statistics facets

**URL:** <https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983>\
**Category:** Elasticsearch\
**Created:** [May 15, 2013, 11:54pm UTC](https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983 "2013-05-15T23:54:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Morelli](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Colin\_Morelli](https://discuss.elastic.co/u/Colin_Morelli)\
**Post date:** [May 15, 2013, 11:54pm UTC](https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983/1 "2013-05-15T23:54:46Z")

</div>

I'm sure that has probably been asked already but my searching didn't come  
up with anything (I really apologize if it has been).

I'm looking to do some analytics with ES. I was wondering if there was any  
way I could leverage the features of date\_histogram while still getting  
additional statistics for each interval. The desired output would be  
something like:

[  
{  
"key": "day 1",  
"sum": 234,  
"count": 12  
},  
{  
"key": "day 2",  
"sum": 353,  
"count": 15  
}  
]

Is it possible to get a sum/average/anything other than a count through the  
date\_histogram facet?

Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 16, 2013, 9:19am UTC](https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983/2 "2013-05-16T09:19:36Z")

</div>

Hi Colin

Have you tried it?

The date histogram outputs the following data:

- "time" - starting time of this bucket
- "count" - total number of docs in this bucket
- "min" - min of value\_field
- "max" - max of value\_field
- "mean" - mean of value\_field
- "total" - sum of value\_field
- "total\_count" - total number of docs in this bucket with a value in  
value\_field

Clint

On 16 May 2013 01:54, Colin Morelli [colin.morelli@gmail.com](mailto:colin.morelli@gmail.com) wrote:

> I'm sure that has probably been asked already but my searching didn't come  
> up with anything (I really apologize if it has been).
> 
> I'm looking to do some analytics with ES. I was wondering if there was any  
> way I could leverage the features of date\_histogram while still getting  
> additional statistics for each interval. The desired output would be  
> something like:
> 
> [  
> {  
> "key": "day 1",  
> "sum": 234,  
> "count": 12  
> },  
> {  
> "key": "day 2",  
> "sum": 353,  
> "count": 15  
> }  
> ]
> 
> Is it possible to get a sum/average/anything other than a count through  
> the date\_histogram facet?
> 
> Thanks
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Colin\_Morelli](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Colin\_Morelli](https://discuss.elastic.co/u/Colin_Morelli)\
**Post date:** [May 16, 2013, 2:02pm UTC](https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983/3 "2013-05-16T14:02:14Z")

</div>

I'm an idiot, completely skipped over the "value\_field" option.

Thanks Clint.

On Thursday, May 16, 2013 5:19:36 AM UTC-4, Clinton Gormley wrote:

> Hi Colin
> 
> Have you tried it?
> 
> The date histogram outputs the following data:
> 
> - "time" - starting time of this bucket
> - "count" - total number of docs in this bucket
> - "min" - min of value\_field
> - "max" - max of value\_field
> - "mean" - mean of value\_field
> - "total" - sum of value\_field
> - "total\_count" - total number of docs in this bucket with a value in  
> value\_field
> 
> Clint
> 
> On 16 May 2013 01:54, Colin Morelli \<[colin....@gmail.com](mailto:colin....@gmail.com) \<javascript:\>\>wrote:
> 
> > I'm sure that has probably been asked already but my searching didn't  
> > come up with anything (I really apologize if it has been).
> > 
> > I'm looking to do some analytics with ES. I was wondering if there was  
> > any way I could leverage the features of date\_histogram while still getting  
> > additional statistics for each interval. The desired output would be  
> > something like:
> > 
> > [  
> > {  
> > "key": "day 1",  
> > "sum": 234,  
> > "count": 12  
> > },  
> > {  
> > "key": "day 2",  
> > "sum": 353,  
> > "count": 15  
> > }  
> > ]
> > 
> > Is it possible to get a sum/average/anything other than a count through  
> > the date\_histogram facet?
> > 
> > Thanks
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:36am UTC](https://discuss.elastic.co/t/combining-date-histogram-with-statistics-facets/11983/4 "2017-07-06T02:36:18Z")

</div>


