# Facet search and missing values

**URL:** <https://discuss.elastic.co/t/facet-search-and-missing-values/9525>\
**Category:** Elasticsearch\
**Created:** [November 2, 2012, 8:47am UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525 "2012-11-02T08:47:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alastair\_James](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alastair_james/32/1180_2.png) [@Alastair\_James](https://discuss.elastic.co/u/Alastair_James)\
**Post date:** [November 2, 2012, 8:47am UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/1 "2012-11-02T08:47:48Z")

</div>

Hi there.

Firstly: ES is a great piece of software. Many thanks!

I am using the term\_stats facets to sum the value of a field 'grouped by' a  
facet key. Not all records in the index have a value for this facet key.

The only problem is dealing with these 'empty' facet keys.

By default, I get a histogram of available facet keys and sum(count).  
However the question is how to work out sum(count) for those records  
without the facet key?

If I were using a simple counting (term) facet (as opposed to term\_stats  
with a sum) I could use the 'missing' value that is returned. However, that  
does not help as I need the sum(count field) for the missing records.

Possible?

Ideally it would be possible to:

- Ask ES to sum the count field for the records without that facet field  
and return as missing\_total
- (Maybe cleaner) Signal that I would like ES to consider a virtual  
'MISSING' facet that gets stats applied, ranked and returned if applicable.

Does that make sense?

Many thanks

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 2, 2012, 5:05pm UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/2 "2012-11-02T17:05:56Z")

</div>

That sounds like a good idea. Could you create an issue for it?

On Friday, November 2, 2012 4:47:48 AM UTC-4, Alastair James wrote:

> Hi there.
> 
> Firstly: ES is a great piece of software. Many thanks!
> 
> I am using the term\_stats facets to sum the value of a field 'grouped by'  
> a facet key. Not all records in the index have a value for this facet key.
> 
> The only problem is dealing with these 'empty' facet keys.
> 
> By default, I get a histogram of available facet keys and sum(count).  
> However the question is how to work out sum(count) for those records  
> without the facet key?
> 
> If I were using a simple counting (term) facet (as opposed to term\_stats  
> with a sum) I could use the 'missing' value that is returned. However, that  
> does not help as I need the sum(count field) for the missing records.
> 
> Possible?
> 
> Ideally it would be possible to:
> 
> - Ask ES to sum the count field for the records without that facet field  
> and return as missing\_total
> - (Maybe cleaner) Signal that I would like ES to consider a virtual  
> 'MISSING' facet that gets stats applied, ranked and returned if applicable.
> 
> Does that make sense?
> 
> Many thanks

--

---

<div class="post-metadata">

**Author:** ![Alastair\_James](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alastair_james/32/1180_2.png) [@Alastair\_James](https://discuss.elastic.co/u/Alastair_James)\
**Post date:** [November 2, 2012, 7:39pm UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/3 "2012-11-02T19:39:39Z")

</div>

Sure... on gtihub?

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 2, 2012, 7:44pm UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/4 "2012-11-02T19:44:03Z")

</div>

Yes, this way we will not forget about it and you will get a notification  
when it's done.

On Friday, November 2, 2012 3:39:39 PM UTC-4, Alastair James wrote:

> Sure... on gtihub?

--

---

<div class="post-metadata">

**Author:** ![Alastair\_James](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alastair_james/32/1180_2.png) [@Alastair\_James](https://discuss.elastic.co/u/Alastair_James)\
**Post date:** [November 14, 2012, 4:27pm UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/5 "2012-11-14T16:27:38Z")

</div>

Ok, great, thanks. Created

> <https://github.com/elastic/elasticsearch/issues/2410>
>
> Hi there.
> 
> I am using the term\_stats facets to sum the value of a field 'grouped… by' a facet key. Not all records in the index have a value for this facet key.
> 
> The only problem is dealing with these 'empty' facet keys.
> 
> By default, I get a histogram of available facet keys and sum(count). However the question is how to work out sum(count) for those records without the facet key?
> 
> If I were using a simple counting (term) facet (as opposed to term\_stats with a sum) I could use the 'missing' value that is returned. However, that does not help as I need the sum(count field) for the missing records.
> 
> Ideally it would be possible to:
> \- Ask ES to sum the count field for the records without that facet field and return as missing\_total
> \- (Maybe cleaner) Signal that I would like ES to consider a virtual 'MISSING' facet that gets stats applied, ranked and returned if applicable.

On Friday, 2 November 2012 19:44:03 UTC, Igor Motov wrote:

> Yes, this way we will not forget about it and you will get a notification  
> when it's done.
> 
> On Friday, November 2, 2012 3:39:39 PM UTC-4, Alastair James wrote:
> 
> > Sure... on gtihub?

--

---

<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:04am UTC](https://discuss.elastic.co/t/facet-search-and-missing-values/9525/6 "2017-07-06T03:04:17Z")

</div>


