Hovo Baghdasaryan
Hovo Baghdasaryan

Reputation: 31

Elasticsearch: Can't add dynamic template in

PUT {index}/_mapping/{type}
{
    
  "dynamic_templates": [
        {
          "float_statistic_fields": {
            "path_match": "statistic.*",
            "match_mapping_type": "*",
            "mapping": {
              "type": "float"
            }
          }
        }
      ]
}

This is an example of how I try to add a dynamic template on some fields of elasticsearch. My statistic field is mapped as an object and after data migration, some fields inside it get text value, I want to map all to float to be able to do the sorting. This query returns success result but not updating in mapping. Could somebody help me

Upvotes: 0

Views: 640

Answers (1)

Val
Val

Reputation: 217564

A dynamic template is only used when fields are getting created the first time. Once the field is created you cannot change its mapping definition anymore (aside from a few exceptions).

Your only option is to create a new index with your dynamic mapping and reindex the current index into the new one that has the right mapping definitions.

Upvotes: 1

Related Questions