# Terms facet/agg not working for nested types in 1.x

**URL:** <https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061>\
**Category:** Elasticsearch\
**Created:** [February 27, 2014, 10:48pm UTC](https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061 "2014-02-27T22:48:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 27, 2014, 10:48pm UTC](https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061/1 "2014-02-27T22:48:04Z")

</div>

I'm running Elasticsearch 1.0.1 with 1 node, 1 shard, 0 replicas for this  
test.

My $ES\_HOME/config/default-mapping.json is the following:  
{  
"_default_": {  
"properties": {  
"foo": {  
"type": "nested",  
"properties": {  
"bar": {  
"index": "analyzed",  
"type": "string"  
}  
}  
}  
}  
}  
}

I add the following doc to test/foobar:  
{  
"foo": {  
"bar": "Foo Bar"  
}  
}

When I POST the following facet (and similar agg):  
{  
"facets": {  
"foobar": {  
"terms": {  
"field": "foo.bar"  
}  
}  
},  
"size": 0  
}

I get the following results:  
{  
took: 52,  
timed\_out: false,  
\_shards: {  
total: 1,  
successful: 1,  
failed: 0  
},  
hits: {  
total: 1,  
max\_score: 0,  
hits: []  
},  
facets: {  
foo: {  
\_type: "terms",  
missing: 1,  
total: 0,  
other: 0  
terms: []  
}  
}  
}

However, the similar setup/facet query worked in 0.90.7.

Please advise if this no longer works in 1.0.1 or if I'm doing something  
wrong.

--  
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/3f3dfe39-99d6-419c-a4d0-c6e0d95a6e93%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3f3dfe39-99d6-419c-a4d0-c6e0d95a6e93%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:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [February 27, 2014, 11:03pm UTC](https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061/2 "2014-02-27T23:03:59Z")

</div>

Try:

{  
"_default_": {  
"properties": {  
"foo": {  
"type": "nested",

- 

```
       "include_in_parent": true,*
      "properties": {
         "bar": {
            "index": "analyzed",
            "type": "string"
         }
      }
   }
}

```

}  
}

It's interesting that it worked in the previous version (I didn't expect it  
to). But the above should work in 1.x.

--  
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/450f2132-43cc-4adf-8580-1b190bf2ed4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/450f2132-43cc-4adf-8580-1b190bf2ed4b%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:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 27, 2014, 11:21pm UTC](https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061/3 "2014-02-27T23:21:01Z")

</div>

That worked!

After further review, I did in fact have that in my 0.90.7 config, but it  
got lost in translation to my 1.0.1 config.

MANY THANKS!!

On Thursday, February 27, 2014 6:03:59 PM UTC-5, Binh Ly wrote:

> Try:
> 
> {  
> "_default_": {  
> "properties": {  
> "foo": {  
> "type": "nested",
> 
> - 
> 
> ```
> "include_in_parent": true,*
> "properties": {
> "bar": {
> "index": "analyzed",
> "type": "string"
> }
> }
> }
> }
> 
> ```
> 
> }  
> }
> 
> It's interesting that it worked in the previous version (I didn't expect  
> it to). But the above should work in 1.x.

--  
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/f4c796a7-83db-4c3e-91c7-cc1286d37150%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f4c796a7-83db-4c3e-91c7-cc1286d37150%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:** ![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, 1:46am UTC](https://discuss.elastic.co/t/terms-facet-agg-not-working-for-nested-types-in-1-x/16061/4 "2017-07-06T01:46:44Z")

</div>


