# How to get Zero count for date Histogram facet for week, day, month, year,hour and quarter?

**URL:** <https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663>\
**Category:** Elasticsearch\
**Created:** [September 18, 2013, 7:10am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663 "2013-09-18T07:10:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vijuitech](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vijuitech](https://discuss.elastic.co/u/vijuitech)\
**Post date:** [September 18, 2013, 7:10am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/1 "2013-09-18T07:10:26Z")

</div>

Hi,  
I am using Elasticsearch version 19.4. I am using date histogram facet to  
get the data based on week, day, month, year,hour and quarter. Is it  
possible get the Zero count data in date histogram facet? I have shown here  
a response for day,

"facets" : {  
"createddaterange" : {  
"\_type" : "date\_histogram",  
"entries" : [ {  
"time" : 1379203200000,  
"count" : 15,  
"min" : 1.3792356E12,  
"max" : 1.3792356E12,  
"total" : 2.0688534E13,  
"total\_count" : 15,  
"mean" : 1.3792356E12  
}, {  
"time" : 1379289600000,  
"count" : 15,  
"min" : 1.379322E12,  
"max" : 1.379322E12,  
"total" : 2.068983E13,  
"total\_count" : 15,  
"mean" : 1.379322E12  
} ]  
}  
}

Could it be possible to get the count for the day without any data as 0  
which would be like,

"facets" : {  
"createddaterange" : {  
"\_type" : "date\_histogram",  
"entries" : [ {  
"time" : 1379203200000,  
"count" : 15,  
"min" : 1.3792356E12,  
"max" : 1.3792356E12,  
"total" : 2.0688534E13,  
"total\_count" : 15,  
"mean" : 1.3792356E12  
}, {  
"time" : 1379289600000,  
"count" : 0,  
"min" : 0,  
"max" : 0,  
"total" : 0,  
"total\_count" : 0,  
"mean" : 0  
} ]  
}  
}

Cheers,  
George

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 18, 2013, 7:17am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/2 "2013-09-18T07:17:58Z")

</div>

Will be AFAIK in upcoming aggregation feature (1.0).

By now, you have to fill blanks on client level.

HTH

David

Le 18 sept. 2013 à 09:10, George Viju [vijuitech@gmail.com](mailto:vijuitech@gmail.com) a écrit :

> Hi,  
> I am using Elasticsearch version 19.4. I am using date histogram facet to get the data based on week, day, month, year,hour and quarter. Is it possible get the Zero count data in date histogram facet? I have shown here a response for day,
> 
> "facets" : {  
> "createddaterange" : {  
> "\_type" : "date\_histogram",  
> "entries" : [ {  
> "time" : 1379203200000,  
> "count" : 15,  
> "min" : 1.3792356E12,  
> "max" : 1.3792356E12,  
> "total" : 2.0688534E13,  
> "total\_count" : 15,  
> "mean" : 1.3792356E12  
> }, {  
> "time" : 1379289600000,  
> "count" : 15,  
> "min" : 1.379322E12,  
> "max" : 1.379322E12,  
> "total" : 2.068983E13,  
> "total\_count" : 15,  
> "mean" : 1.379322E12  
> } ]  
> }  
> }
> 
> Could it be possible to get the count for the day without any data as 0 which would be like,
> 
> "facets" : {  
> "createddaterange" : {  
> "\_type" : "date\_histogram",  
> "entries" : [ {  
> "time" : 1379203200000,  
> "count" : 15,  
> "min" : 1.3792356E12,  
> "max" : 1.3792356E12,  
> "total" : 2.0688534E13,  
> "total\_count" : 15,  
> "mean" : 1.3792356E12  
> }, {  
> "time" : 1379289600000,  
> "count" : 0,  
> "min" : 0,  
> "max" : 0,  
> "total" : 0,  
> "total\_count" : 0,  
> "mean" : 0  
> } ]  
> }  
> }
> 
> Cheers,  
> George
> 
> --  
> 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:** ![vijuitech](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vijuitech](https://discuss.elastic.co/u/vijuitech)\
**Post date:** [September 18, 2013, 7:25am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/3 "2013-09-18T07:25:08Z")

</div>

Thank you David. I couldn't get your point " fill blanks on client level.  
". Could you please give me an example regarding this which would be help  
me better understanding?

On Wednesday, 18 September 2013 12:47:58 UTC+5:30, David Pilato wrote:

> Will be AFAIK in upcoming aggregation feature (1.0).
> 
> By now, you have to fill blanks on client level.
> 
> HTH
> 
> David
> 
> Le 18 sept. 2013 à 09:10, George Viju \<[viju...@gmail.com](mailto:viju...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hi,  
> I am using Elasticsearch version 19.4. I am using date histogram facet to  
> get the data based on week, day, month, year,hour and quarter. Is it  
> possible get the Zero count data in date histogram facet? I have shown here  
> a response for day,
> 
> "facets" : {  
> "createddaterange" : {  
> "\_type" : "date\_histogram",  
> "entries" : [ {  
> "time" : 1379203200000,  
> "count" : 15,  
> "min" : 1.3792356E12,  
> "max" : 1.3792356E12,  
> "total" : 2.0688534E13,  
> "total\_count" : 15,  
> "mean" : 1.3792356E12  
> }, {  
> "time" : 1379289600000,  
> "count" : 15,  
> "min" : 1.379322E12,  
> "max" : 1.379322E12,  
> "total" : 2.068983E13,  
> "total\_count" : 15,  
> "mean" : 1.379322E12  
> } ]  
> }  
> }
> 
> Could it be possible to get the count for the day without any data as 0  
> which would be like,
> 
> "facets" : {  
> "createddaterange" : {  
> "\_type" : "date\_histogram",  
> "entries" : [ {  
> "time" : 1379203200000,  
> "count" : 15,  
> "min" : 1.3792356E12,  
> "max" : 1.3792356E12,  
> "total" : 2.0688534E13,  
> "total\_count" : 15,  
> "mean" : 1.3792356E12  
> }, {  
> "time" : 1379289600000,  
> "count" : 0,  
> "min" : 0,  
> "max" : 0,  
> "total" : 0,  
> "total\_count" : 0,  
> "mean" : 0  
> } ]  
> }  
> }
> 
> Cheers,  
> George
> 
> --  
> 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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 18, 2013, 7:28am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/4 "2013-09-18T07:28:50Z")

</div>

That basically means that you now on client side that for example you have a year interval.

So if you get as a result:  
2010: 10  
2012: 2  
2013: 3

You know on client side that 2011 is missing, right?

Just add it yourself on client side in the array of results:  
2010: 10  
2011: 0  
2012: 2  
2013: 3

## That's what I meant.

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 18 sept. 2013 à 09:25, George Viju [vijuitech@gmail.com](mailto:vijuitech@gmail.com) a écrit :

> Thank you David. I couldn't get your point " fill blanks on client level. ". Could you please give me an example regarding this which would be help me better understanding?
> 
> On Wednesday, 18 September 2013 12:47:58 UTC+5:30, David Pilato wrote:  
> Will be AFAIK in upcoming aggregation feature (1.0).
> 
> By now, you have to fill blanks on client level.
> 
> HTH
> 
> David
> 
> Le 18 sept. 2013 à 09:10, George Viju [viju...@gmail.com](mailto:viju...@gmail.com) a écrit :
> 
> > Hi,  
> > I am using Elasticsearch version 19.4. I am using date histogram facet to get the data based on week, day, month, year,hour and quarter. Is it possible get the Zero count data in date histogram facet? I have shown here a response for day,
> > 
> > "facets" : {  
> > "createddaterange" : {  
> > "\_type" : "date\_histogram",  
> > "entries" : [ {  
> > "time" : 1379203200000,  
> > "count" : 15,  
> > "min" : 1.3792356E12,  
> > "max" : 1.3792356E12,  
> > "total" : 2.0688534E13,  
> > "total\_count" : 15,  
> > "mean" : 1.3792356E12  
> > }, {  
> > "time" : 1379289600000,  
> > "count" : 15,  
> > "min" : 1.379322E12,  
> > "max" : 1.379322E12,  
> > "total" : 2.068983E13,  
> > "total\_count" : 15,  
> > "mean" : 1.379322E12  
> > } ]  
> > }  
> > }
> > 
> > Could it be possible to get the count for the day without any data as 0 which would be like,
> > 
> > "facets" : {  
> > "createddaterange" : {  
> > "\_type" : "date\_histogram",  
> > "entries" : [ {  
> > "time" : 1379203200000,  
> > "count" : 15,  
> > "min" : 1.3792356E12,  
> > "max" : 1.3792356E12,  
> > "total" : 2.0688534E13,  
> > "total\_count" : 15,  
> > "mean" : 1.3792356E12  
> > }, {  
> > "time" : 1379289600000,  
> > "count" : 0,  
> > "min" : 0,  
> > "max" : 0,  
> > "total" : 0,  
> > "total\_count" : 0,  
> > "mean" : 0  
> > } ]  
> > }  
> > }
> > 
> > Cheers,  
> > George
> > 
> > --  
> > 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).  
> > 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).

--  
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:** ![vijuitech](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vijuitech](https://discuss.elastic.co/u/vijuitech)\
**Post date:** [September 18, 2013, 7:33am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/5 "2013-09-18T07:33:14Z")

</div>

Thank you so much David.

cheers,  
George

On Wednesday, 18 September 2013 12:58:50 UTC+5:30, David Pilato wrote:

> That basically means that you now on client side that for example you have  
> a year interval.
> 
> So if you get as a result:  
> 2010: 10  
> 2012: 2  
> 2013: 3
> 
> You know on client side that 2011 is missing, right?
> 
> Just add it yourself on client side in the array of results:  
> 2010: 10  
> 2011: 0  
> 2012: 2  
> 2013: 3
> 
> ## That's what I meant.
> 
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 18 sept. 2013 à 09:25, George Viju \<[viju...@gmail.com](mailto:viju...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Thank you David. I couldn't get your point " fill blanks on client level.  
> ". Could you please give me an example regarding this which would be help  
> me better understanding?
> 
> On Wednesday, 18 September 2013 12:47:58 UTC+5:30, David Pilato wrote:
> 
> > Will be AFAIK in upcoming aggregation feature (1.0).
> > 
> > By now, you have to fill blanks on client level.
> > 
> > HTH
> > 
> > David
> > 
> > Le 18 sept. 2013 à 09:10, George Viju [viju...@gmail.com](mailto:viju...@gmail.com) a écrit :
> > 
> > Hi,  
> > I am using Elasticsearch version 19.4. I am using date histogram facet to  
> > get the data based on week, day, month, year,hour and quarter. Is it  
> > possible get the Zero count data in date histogram facet? I have shown here  
> > a response for day,
> > 
> > "facets" : {  
> > "createddaterange" : {  
> > "\_type" : "date\_histogram",  
> > "entries" : [ {  
> > "time" : 1379203200000,  
> > "count" : 15,  
> > "min" : 1.3792356E12,  
> > "max" : 1.3792356E12,  
> > "total" : 2.0688534E13,  
> > "total\_count" : 15,  
> > "mean" : 1.3792356E12  
> > }, {  
> > "time" : 1379289600000,  
> > "count" : 15,  
> > "min" : 1.379322E12,  
> > "max" : 1.379322E12,  
> > "total" : 2.068983E13,  
> > "total\_count" : 15,  
> > "mean" : 1.379322E12  
> > } ]  
> > }  
> > }
> > 
> > Could it be possible to get the count for the day without any data as 0  
> > which would be like,
> > 
> > "facets" : {  
> > "createddaterange" : {  
> > "\_type" : "date\_histogram",  
> > "entries" : [ {  
> > "time" : 1379203200000,  
> > "count" : 15,  
> > "min" : 1.3792356E12,  
> > "max" : 1.3792356E12,  
> > "total" : 2.0688534E13,  
> > "total\_count" : 15,  
> > "mean" : 1.3792356E12  
> > }, {  
> > "time" : 1379289600000,  
> > "count" : 0,  
> > "min" : 0,  
> > "max" : 0,  
> > "total" : 0,  
> > "total\_count" : 0,  
> > "mean" : 0  
> > } ]  
> > }  
> > }
> > 
> > Cheers,  
> > George
> > 
> > --  
> > 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).  
> > 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 [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:15am UTC](https://discuss.elastic.co/t/how-to-get-zero-count-for-date-histogram-facet-for-week-day-month-year-hour-and-quarter/13663/6 "2017-07-06T02:15:49Z")

</div>


