# How to apply mappings just once?

**URL:** <https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280>\
**Category:** Elasticsearch\
**Created:** [May 15, 2019, 10:55pm UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280 "2019-05-15T22:55:17Z")\
**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:** [May 15, 2019, 10:55pm UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280/1 "2019-05-15T22:55:18Z")

</div>

Hello, maybe the subject is a little bit unclear... Sorry

Elasticsearch 5.6.10

First time I tried to sort some field in the Kibana dashboard, I got an error message like "Fielddata is disabled on text fields by default". After googling that error message, I managed to solve it by running a command like this

```
curl -X PUT "my.host.name:9200/myindex-*/_mapping/logs" -H 'Content-Type: application/json' -d'
{
  "properties": {
    "field1": {
      "type": "text",
      "fielddata": true
    },
    "field2": {
      "type": "text",
      "fielddata": true
    }
  }
}
'

```

It worked fine at that time.  
However, if I try to sort again, now I am getting another error message saying that some of the shards failed.  
Running the command again solves the issue.

Is it possible the command only works with the indices that exist, but it does not affect new ones created after it, even though they have the same pattern?

I feel I am missing something basic here, but as I don't know what it is, I don't know how to investigate it.  
If someone can just tell me the keywords, I can take from there and start investigating. A direct link to the documentation would be even better 🙂

Thanks a lot in advance.

---

<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:** [May 16, 2019, 10:42pm UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280/2 "2019-05-16T22:42:18Z")

</div>

should I change the subject to make it more clear? Any suggestion?

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [May 17, 2019, 12:29am UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280/3 "2019-05-17T00:29:26Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)

---

<div class="post-metadata">

**Author:** ![gbrown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gbrown/32/34482_2.png) [@gbrown](https://discuss.elastic.co/u/gbrown)\
**Post date:** [May 17, 2019, 5:31am UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280/4 "2019-05-17T05:31:43Z")

</div>

Hi Jose,

I'm not certain why you're getting an error message, but enabling fielddata to allow sorting on a `text` field is not recommended. Enabling fielddata for text fields consumes a **lot** of memory, and you should generally explore other alteratives to accomplish the same goal, such as adding a `keyword` multifield, which will be much more efficient.

You can see how to do this [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/fielddata.html#before-enabling-fielddata) - that page also describes why enabling fielddata on text fields is not recommended. You may need to reindex your data to apply some of these solutions.

If you want help troubleshooting the cause of the error you mentioned, you'll need to post the full error message.

---

<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:** [June 14, 2019, 5:31am UTC](https://discuss.elastic.co/t/how-to-apply-mappings-just-once/181280/5 "2019-06-14T05:31:49Z")

</div>

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