# Possible to get 0 count facet values back?

**URL:** <https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515>\
**Category:** Elasticsearch\
**Created:** [January 26, 2012, 7:17pm UTC](https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515 "2012-01-26T19:17:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Bashford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_bashford/32/3007_2.png) [@David\_Bashford](https://discuss.elastic.co/u/David_Bashford)\
**Post date:** [January 26, 2012, 7:17pm UTC](https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515/1 "2012-01-26T19:17:26Z")

</div>

Old Solr user, brand new ElasticSearch user. With Solr if I do date  
faceting and use a 24 hour range with a 1 hour gap, it'll return 24 results  
with the corresponding values, even if the value is 0, which is real useful  
when my goal is to take those numbers and toss them on a nice evenly spaced  
line chart. You sort of expect that if only 2 hours of the day had hits,  
that you'd have a long flatline with 2 spikes.

Can't quite figure out how to get ES to return me the 0 values. Is that  
possible or do I need to hand wedge them in.

Thanks so much!

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 27, 2012, 8:47pm UTC](https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515/2 "2012-01-27T20:47:04Z")

</div>

Which facet are you using? If its histogram facet, then yes, it will only return buckets that have actual data to reserve space. Most charing systems can fill in the gaps easily for you, where you just need to provide the ones with data.

On Thursday, January 26, 2012 at 9:17 PM, David Bashford wrote:

> Old Solr user, brand new Elasticsearch user. With Solr if I do date faceting and use a 24 hour range with a 1 hour gap, it'll return 24 results with the corresponding values, even if the value is 0, which is real useful when my goal is to take those numbers and toss them on a nice evenly spaced line chart. You sort of expect that if only 2 hours of the day had hits, that you'd have a long flatline with 2 spikes.
> 
> Can't quite figure out how to get ES to return me the 0 values. Is that possible or do I need to hand wedge them in.
> 
> Thanks so much!

---

<div class="post-metadata">

**Author:** ![Jamie\_Matthews](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jamie_matthews/32/2669_2.png) [@Jamie\_Matthews](https://discuss.elastic.co/u/Jamie_Matthews)\
**Post date:** [March 21, 2012, 12:20pm UTC](https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515/3 "2012-03-21T12:20:43Z")

</div>

Hi,

Another new ES user here, and I have the same issue as the original author.

On Friday, January 27, 2012 8:47:04 PM UTC, kimchy wrote:

> Most charing systems can fill in the gaps easily for you, where you just  
> need to provide the ones with data.

Just FYI, this is actually not the case with many charting libraries. Say  
you have the following data (pseudocode, obviously):

dates: ["March 21st", "March 20th", "March 19th", "March 18th", "March  
17th"]  
counts: [5, 6, 0, 10, 5]

Elasticsearch will return the following:

dates: ["March 21st", "March 20th", "March 18th", "March 17th"]  
counts: [5, 6, 10, 5]

Most charting libraries will actually draw a straight line between 6 and  
10, rather than dipping to 0 for March 19th as expected.

Although you can get round this by preprocessing the data, it's quite  
fiddly. It'd be really nice if the date histogram facet at least provided  
an _option_ to include zero data points.

Cheers,

Jamie

---

<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, 3:35am UTC](https://discuss.elastic.co/t/possible-to-get-0-count-facet-values-back/6515/4 "2017-07-06T03:35:17Z")

</div>


