Home > Software design >  Elastic Search - How to update mapping field from keyword to text
Elastic Search - How to update mapping field from keyword to text

Time:12-21

{
   "properties":{
      "device":{
         "type":"object",
         "properties":{
            "id":{
               "type":"keyword"
            },
            "value":{
               "type":"keyword"
            }
         }
      }
   }
}

I wanted to update mapping value as text, when I'm trying to update using https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html throws an error. "mapper [device.value] of different type, current_type [keyword], merged_type [text]"

{
   "properties":{
      "device":{
         "type":"object",
         "properties":{
            "id":{
               "type":"keyword"
            },
            "value":{
               "type":"text"
            }
         }
      }
   }
}

Someone help me update index from keyword to text?

CodePudding user response:

Changing field type is a breaking change, you need to

  1. Create a new index with new required mapping.

  2. use reindex API to move data from old to new index(optional if you are OK with data loss)

  • Related