# Update API breaks the Terms facet

**URL:** <https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124>\
**Category:** Elasticsearch\
**Created:** [December 19, 2012, 5:14pm UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124 "2012-12-19T17:14:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charith](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Charith](https://discuss.elastic.co/u/Charith)\
**Post date:** [December 19, 2012, 5:14pm UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124/1 "2012-12-19T17:14:11Z")

</div>

Hi,

Elastic Search Version: 0.19.8

I have run into a strange problem after using the update API to add a new  
nested field to an existing index. The update went through fine and I can  
query the index using the newly added field. However, if I try to run a  
terms facet on the new field, no results are returned and the "missing"  
attribute is set to the total number of documents in the index. When I  
look at the source, the data actually exists - so there is no reason for it  
to be marked as missing.  
Has anybody else encountered this before? Here's a gist that recreates the  
issue: [https://gist.github.com/4338257](https://gist.github.com/4338257)

Thanks in advance.

--

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [December 19, 2012, 9:25pm UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124/2 "2012-12-19T21:25:58Z")

</div>

Hi,

If you facet want to facet on nested properties you need to specify in  
the facet request part. In your case if you add the following to the  
`p` facet:  
"nested" : "nested\_impression"

Also a refresh needs to have happened after the updates have been  
completed. By default this happens every second.  
When I ran your gist I added a call to the refresh api. The search  
result is now as expected. See my gist:

> <https://gist.github.com/martijnvg/4340646>

Martijn

On 19 December 2012 18:14, Charith \*@otiose.me wrote:

> Hi,
> 
> Elastic Search Version: 0.19.8
> 
> I have run into a strange problem after using the update API to add a new  
> nested field to an existing index. The update went through fine and I can  
> query the index using the newly added field. However, if I try to run a  
> terms facet on the new field, no results are returned and the "missing"  
> attribute is set to the total number of documents in the index. When I look  
> at the source, the data actually exists - so there is no reason for it to be  
> marked as missing.  
> Has anybody else encountered this before? Here's a gist that recreates the  
> issue: [Elastic Search Terms Facet Weirdness · GitHub](https://gist.github.com/4338257)
> 
> Thanks in advance.
> 
> --

--  
Met vriendelijke groet,

Martijn van Groningen

--

---

<div class="post-metadata">

**Author:** ![Charith](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Charith](https://discuss.elastic.co/u/Charith)\
**Post date:** [December 20, 2012, 8:39am UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124/3 "2012-12-20T08:39:36Z")

</div>

Wow, thanks so much Martijn. It never occurred to me to do a nested facet  
because all my other nested fields had "include\_in\_root" set to true. I  
feel very stupid now.

Thanks once again.

On Wednesday, 19 December 2012 21:25:58 UTC, Martijn v Groningen wrote:

> Hi,
> 
> If you facet want to facet on nested properties you need to specify in  
> the facet request part. In your case if you add the following to the  
> `p` facet:  
> "nested" : "nested\_impression"
> 
> Also a refresh needs to have happened after the updates have been  
> completed. By default this happens every second.  
> When I ran your gist I added a call to the refresh api. The search  
> result is now as expected. See my gist:  
> [gist:4340646 · GitHub](https://gist.github.com/4340646)
> 
> Martijn
> 
> On 19 December 2012 18:14, Charith \*@otiose.me wrote:
> 
> > Hi,
> > 
> > Elastic Search Version: 0.19.8
> > 
> > I have run into a strange problem after using the update API to add a  
> > new  
> > nested field to an existing index. The update went through fine and I  
> > can  
> > query the index using the newly added field. However, if I try to run a  
> > terms facet on the new field, no results are returned and the "missing"  
> > attribute is set to the total number of documents in the index. When I  
> > look  
> > at the source, the data actually exists - so there is no reason for it  
> > to be  
> > marked as missing.  
> > Has anybody else encountered this before? Here's a gist that recreates  
> > the  
> > issue: [Elastic Search Terms Facet Weirdness · GitHub](https://gist.github.com/4338257)
> > 
> > Thanks in advance.
> > 
> > --
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [December 20, 2012, 9:18am UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124/4 "2012-12-20T09:18:04Z")

</div>

No worries 🙂

On 20 December 2012 09:39, Charith \*@otiose.me wrote:

> Wow, thanks so much Martijn. It never occurred to me to do a nested facet  
> because all my other nested fields had "include\_in\_root" set to true. I feel  
> very stupid now.
> 
> Thanks once again.
> 
> On Wednesday, 19 December 2012 21:25:58 UTC, Martijn v Groningen wrote:
> 
> > Hi,
> > 
> > If you facet want to facet on nested properties you need to specify in  
> > the facet request part. In your case if you add the following to the  
> > `p` facet:  
> > "nested" : "nested\_impression"
> > 
> > Also a refresh needs to have happened after the updates have been  
> > completed. By default this happens every second.  
> > When I ran your gist I added a call to the refresh api. The search  
> > result is now as expected. See my gist:  
> > [gist:4340646 · GitHub](https://gist.github.com/4340646)
> > 
> > Martijn
> > 
> > On 19 December 2012 18:14, Charith \*@otiose.me wrote:
> > 
> > > Hi,
> > > 
> > > Elastic Search Version: 0.19.8
> > > 
> > > I have run into a strange problem after using the update API to add a  
> > > new  
> > > nested field to an existing index. The update went through fine and I  
> > > can  
> > > query the index using the newly added field. However, if I try to run a  
> > > terms facet on the new field, no results are returned and the "missing"  
> > > attribute is set to the total number of documents in the index. When I  
> > > look  
> > > at the source, the data actually exists - so there is no reason for it  
> > > to be  
> > > marked as missing.  
> > > Has anybody else encountered this before? Here's a gist that recreates  
> > > the  
> > > issue: [Elastic Search Terms Facet Weirdness · GitHub](https://gist.github.com/4338257)
> > > 
> > > Thanks in advance.
> > > 
> > > --
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
Met vriendelijke groet,

Martijn van Groningen

--

---

<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:59am UTC](https://discuss.elastic.co/t/update-api-breaks-the-terms-facet/10124/5 "2017-07-06T02:59:10Z")

</div>


