# Facet count for nested value "no" is missing

**URL:** <https://discuss.elastic.co/t/facet-count-for-nested-value-no-is-missing/14898>\
**Category:** Elasticsearch\
**Created:** [December 17, 2013, 12:01am UTC](https://discuss.elastic.co/t/facet-count-for-nested-value-no-is-missing/14898 "2013-12-17T00:01:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_2/32/1875_2.png) [@Nathan\_2](https://discuss.elastic.co/u/Nathan_2)\
**Post date:** [December 17, 2013, 12:01am UTC](https://discuss.elastic.co/t/facet-count-for-nested-value-no-is-missing/14898/1 "2013-12-17T00:01:38Z")

</div>

I have a nested field with possible values of "yes", "no", "maybe". It is  
type "string", not analyzed. When I ask for facet counts for this field  
(terms facet), I get back counts for "yes" and "maybe", and then the count  
that I would expect for "no" is in the missing count, instead of in the  
terms list. It is acting like "no" has some type of special handling or  
behavior. I am unable to find any reference to a special behavior like  
this in the docs. Is there some way to get the value "no" to behave  
normally?

I tested that it works fine to have "no" in a non-nested field, so it seems  
to be specific to nesting.

data (python code):

```
    [{
        'id' : 1,
        'recommendations' : [{
            'username' : 'user0',
            'recommendation' : 'yes',
        }]
    },
    {
        'id' : 10,
        'recommendations' : [{
            'username' : 'user0',
            'recommendation' : 'no',
        }]
    },
    {
        'id' : 7,
        'recommendations' : [{
            'username' : 'user0',
            'recommendation' : 'maybe',
        }]
    },]

```

query:

{  
'query': {  
'match\_all': {}  
},  
'facets': {  
'recommendations': {  
'terms': {  
'field': 'recommendations.recommendation',  
'size': 10},  
'nested': 'recommendations'  
}  
}  
}

facets in the results:

'facets': {  
'recommendations': {  
'\_type': 'terms',  
'total': 2,  
'terms': [{  
'count': 1, u'term': u'yes'  
}, {  
'count': 1, u'term': u'maybe'  
}],  
'other': 0,  
'missing': 1  
}  
}

Thanks for any help!

Nathan

--  
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/d7a703e3-3ee6-41fe-971b-8485c83a52d3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d7a703e3-3ee6-41fe-971b-8485c83a52d3%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Nathan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_2/32/1875_2.png) [@Nathan\_2](https://discuss.elastic.co/u/Nathan_2)\
**Post date:** [December 17, 2013, 4:09am UTC](https://discuss.elastic.co/t/facet-count-for-nested-value-no-is-missing/14898/2 "2013-12-17T04:09:37Z")

</div>

Ok, I figured it out. It turns out that index: not\_analyzed doesn’t get inherited from the parent, for nested properties. I thought that

‘recommendations’ : {  
‘type’ : ‘nested’,  
‘index’ : ‘not\_analyzed’,  
‘properties’ : {  
‘recommendation’ : {  
‘type’ : ‘string’  
}  
}  
}

would make recommendations.recommendation be not\_analyzed, but that wasn’t true. moving index: not\_analyzed down to the recommendation property fixed the problem.

Nathan

On Dec 16, 2013, at 5:01 PM, Nathan [nathannospam@gmail.com](mailto:nathannospam@gmail.com) wrote:

> I have a nested field with possible values of "yes", "no", "maybe". It is type "string", not analyzed. When I ask for facet counts for this field (terms facet), I get back counts for "yes" and "maybe", and then the count that I would expect for "no" is in the missing count, instead of in the terms list. It is acting like "no" has some type of special handling or behavior. I am unable to find any reference to a special behavior like this in the docs. Is there some way to get the value "no" to behave normally?
> 
> I tested that it works fine to have "no" in a non-nested field, so it seems to be specific to nesting.
> 
> data (python code):
> 
> ```
> [{
> 'id' : 1,
> 'recommendations' : [{
> 'username' : 'user0',
> 'recommendation' : 'yes',
> }]
> },
> {
> 'id' : 10,
> 'recommendations' : [{
> 'username' : 'user0',
> 'recommendation' : 'no',
> }]
> },
> {
> 'id' : 7,
> 'recommendations' : [{
> 'username' : 'user0',
> 'recommendation' : 'maybe',
> }]
> },]
> 
> ```
> 
> query:
> 
> {  
> 'query': {  
> 'match\_all': {}  
> },  
> 'facets': {  
> 'recommendations': {  
> 'terms': {  
> 'field': 'recommendations.recommendation',  
> 'size': 10},  
> 'nested': 'recommendations'  
> }  
> }  
> }
> 
> facets in the results:
> 
> 'facets': {  
> 'recommendations': {  
> '\_type': 'terms',  
> 'total': 2,  
> 'terms': [{  
> 'count': 1, u'term': u'yes'  
> }, {  
> 'count': 1, u'term': u'maybe'  
> }],  
> 'other': 0,  
> 'missing': 1  
> }  
> }
> 
> Thanks for any help!
> 
> Nathan
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/tOuUs9ruFn0/unsubscribe](https://groups.google.com/d/topic/elasticsearch/tOuUs9ruFn0/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/d7a703e3-3ee6-41fe-971b-8485c83a52d3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d7a703e3-3ee6-41fe-971b-8485c83a52d3%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6E1A2557-15D6-41E0-9624-EA459E94FFEF%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/6E1A2557-15D6-41E0-9624-EA459E94FFEF%40gmail.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:00am UTC](https://discuss.elastic.co/t/facet-count-for-nested-value-no-is-missing/14898/3 "2017-07-06T02:00:48Z")

</div>


