# ES has broken terms facet after mapping update

**URL:** <https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804>\
**Category:** Elasticsearch\
**Created:** [April 8, 2016, 12:35pm UTC](https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804 "2016-04-08T12:35:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_6](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_6/32/1330_2.png) [@Alex\_6](https://discuss.elastic.co/u/Alex_6)\
**Post date:** [April 8, 2016, 12:35pm UTC](https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804/1 "2016-04-08T12:35:52Z")

</div>

ES 1.5.1, Kibana 3.  
I recently updated the mapping template for an index/type to use doc\_value:

```
{
  "order": 0,
  "template": "containerlogs-*",
  "settings": {},
  "mappings": {
    "ContainerLog": {
      "properties": {
        "path": {
          "index": "not_analyzed",
          "type": "string",
          "doc_values": true <<< new line
        },
        "host": {
          "index": "not_analyzed",
          "type": "string",
          "doc_values": true <<< new line
        }
      }
    }
  },
  "aliases": {}
}

```

We use daily indexes. In our Kibana dashboard we have a terms panel for the field `environment` (note that it's not even in the template). After the change that panel is now inexplicably returning all results as `Missing field` in that panel for all indexes since the change. However, I can still query and filter based on the field, and all the results in a table show as having a value for `environment`‼

I grabbed [the query](https://gist.github.com/anonymous/c6aebcf5ef249f30233f374c911ebee1) that the panel was running and did a curl directly and ES is indeed returning everything as `Missing field`. Running the query on an older index _does_ return the correct result (just as Kibana showed). I then went ultra basic and did a query like `/_search?q=environment:prd` on both an older and newer index and they both returned results. So it's something about the terms query.

Both an older and newer index have the same mapping for environment: `"environment" : { "type" : "string" }`.

I'm not seeing anything related to this in the ES client node's log. Any ideas?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 9, 2016, 10:56pm UTC](https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804/2 "2016-04-09T22:56:25Z")

</div>

Facets are not compatible with doc values, that may why.

---

<div class="post-metadata">

**Author:** ![Alex\_6](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_6/32/1330_2.png) [@Alex\_6](https://discuss.elastic.co/u/Alex_6)\
**Post date:** [April 11, 2016, 3:37pm UTC](https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804/3 "2016-04-11T15:37:00Z")

</div>

Well I tried adding the same settings for environment and now it has started working on a new daily index. This is really strange.

```
"environment": {
          "index": "not_analyzed",
          "type": "string",
          "doc_values": true
        }

```

It seems like changing the doc\_values setting on one field has changed how facets work on another field. But then turning on doc\_values for that field makes the facets work again.

I realise this is an old version of Kibana and ES so it doesn't matter much, but any explanations?

---

<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 5, 2017, 11:00pm UTC](https://discuss.elastic.co/t/es-has-broken-terms-facet-after-mapping-update/46804/4 "2017-07-05T23:00:41Z")

</div>


