How to apply mappings just once?

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 :slight_smile:

Thanks a lot in advance.

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

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

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 - 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.

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