# How to solve "Fielddata is disabled on text fields by default"

**URL:** <https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322>\
**Category:** Elasticsearch\
**Created:** [July 25, 2019, 8:56pm UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322 "2019-07-25T20:56:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcaballero](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jcaballero](https://discuss.elastic.co/u/jcaballero)\
**Post date:** [July 25, 2019, 8:56pm UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322/1 "2019-07-25T20:56:59Z")

</div>

Hi [again],

I already opened a while ago a Topic on this issue, but it expired. So I am opening a new one.

[https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280)

ElasticSearch 5.6.10

When I try to sort in Kibana a given field from data in ElasticSearch, I get the famous message "Fielddata is disabled on text fields by default". So I need to:

1. convert that field for all existing indices
2. make it that new indices, created daily, have already the right settings

I was pointed to [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-templates.html)

but I have to admit I don't fully understand it.  
From what I have read in other parts of the documentation, it is not possible to modify existing indices. Right?

If not possible to get 1. and 2., then my priority is 2.  
I have tried to apply a template for a fake index that does not exist yet, like this

```
 curl -X PUT "my.elasticsearch.host:9200/_template/template_1" -H 'Content-Type: application/json' -d'
{
  "template": "test*",
  "settings" : {
    "number_of_shards":1
  },
  "mappings": {
    "log": {
        "_source": {
          "enabled": false
        },
        "properties": {
          "user": {
            "type": "keyword"
          }
        }
    }
  }
}
'

```

and then tried to add a few documents to several indices:

```
curl -X PUT "my.elasticsearch.host:9200/test-1/log/1?pretty" -H 'Content-Type: application/json' -d '{ "user": "joe"}'
curl -X PUT "my.elasticsearch.host:9200/test-1/log/2?pretty" -H 'Content-Type: application/json' -d '{ "user": "jane"}'
curl -X PUT "my.elasticsearch.host:9200/test-2/log/1?pretty" -H 'Content-Type: application/json' -d '{ "user": "dan"}'
curl -X PUT "my.elasticsearch.host:9200/test-3/log/1?pretty" -H 'Content-Type: application/json' -d '{ "user": "mike"}'
curl -X PUT "my.elasticsearch.host:9200/test-3/log/2?pretty" -H 'Content-Type: application/json' -d '{ "user": "freddy"}'

```

However, that does not seem to work. When I query, I don't see the "user" in the output anywhere.  
What am I missing?

---

<div class="post-metadata">

**Author:** ![jcaballero](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jcaballero](https://discuss.elastic.co/u/jcaballero)\
**Post date:** [July 25, 2019, 10:08pm UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322/2 "2019-07-25T22:08:19Z")

</div>

OK... replying to myself. This template seems to do the trick for new documents.

```
curl -X PUT "my.elasticsearch.host:9200/_template/template_1" -H 'Content-Type: application/json' -d'
{
  "template": "test*",
  "mappings": {
     "log" : {
        "properties": {
          "user": {
            "type": "keyword"
        }
       }
    }
  }
}
'

```

Still don't know how to apply it to existing documents already stored. Maybe that is not possible.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 26, 2019, 6:45am UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322/3 "2019-07-26T06:45:34Z")

</div>

Not possible but the “reindex” api will allow you to copy the old docs to an index with the correct mapping

---

<div class="post-metadata">

**Author:** ![jcaballero](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jcaballero](https://discuss.elastic.co/u/jcaballero)\
**Post date:** [July 26, 2019, 2:00pm UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322/4 "2019-07-26T14:00:06Z")

</div>

thanks !!

---

<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:** [August 23, 2019, 2:07pm UTC](https://discuss.elastic.co/t/how-to-solve-fielddata-is-disabled-on-text-fields-by-default/192322/5 "2019-08-23T14:07:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
