# Elasticsearch error: Fielddata is disabled on text fields by default

**URL:** https://discuss.elastic.co/t/elasticsearch-error-fielddata-is-disabled-on-text-fields-by-default/189779
**Category:** Elasticsearch
**Created:** [July 10, 2019, 1:38pm UTC](https://discuss.elastic.co/t/elasticsearch-error-fielddata-is-disabled-on-text-fields-by-default/189779 "2019-07-10T13:38:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)
#### Post date: [July 10, 2019, 1:38pm UTC](https://discuss.elastic.co/t/elasticsearch-error-fielddata-is-disabled-on-text-fields-by-default/189779/1 "2019-07-10T13:38:07Z")

</div>

hi all,  
I have a field as PFiled which its format is as following:  
1398-04-14  
it is not a date field, but elasticsearch defined its mapping as date which is wrong. I define template to set it as text as following:

```
PUT _template/template1
{
"index_patterns" : [
   "index1*"
   ],
"mappings" : {
      "doc" : {
        "properties" : {
          "PField" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            } }

}
}
}
}

```

running above command in dev tools, leads to following error:

```
failed to execute fetch phase
org.elasticsearch.transport.RemoteTransportException: [node-SRV123][localhost:9300][indices:data/read/search[phase/fetch/id]]
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [PField] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

```

there are many other text fields which elasticsearch defined them as text by default; there is no issue in the case of that fields, but when i defined PField as a text field this message has been found in the log. how can i handle this issue? this field cannot be configured as Date because it is not Date and defining text type leads to above error. could you please advise me about this?

@Badger

---

<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 7, 2019, 1:38pm UTC](https://discuss.elastic.co/t/elasticsearch-error-fielddata-is-disabled-on-text-fields-by-default/189779/2 "2019-08-07T13:38:16Z")

</div>

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