Deleting part of mapping in Elasticsearch 1.7


(Nemo) #1

Hi All,

By mistake I added a wrong mapping as below

"person_info" : {
        "_timestamp" : {
          "enabled" : true,
          "store" : true
        },
        "properties" : {
          "entry_time" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "address" : {
            "properties" : {
              "local_address" : {
                "properties" : {
                   "street" : {
                    "type" : "string"
                  },
                  "city" : {
                    "type" : "string"
                  },
                  "zip" : {
                    "type" : "string"
                  }
              }
              "local_address" : {
                "properties" : {
                  "street" : {
                    "type" : "string"
                  },
                  "city" : {
                    "type" : "string"
                  },
                  "zip" : {
                    "type" : "long"
                  }
                }
              }
            }
          }       
        }
      }
    }

where zip is string in one mapping and long in another. Is there any way to remove any one of the mapping?

Regards,


(wyhw) #2

Once mapping have created , can not be modified manually


(Nemo) #3

Thank you.


(Nemo) #4

I don't mind losing one of the mapping data. What is the best way to to migrate to 2.2 from 1.7? For sure I will get mapping exception if I move to 2.2


(Yannick Welsch) #5

You can use the Elasticsearch Migration Plugin to check whether you can safely upgrade.


(Nemo) #6

It says I cannot upgrade.

Conflicting field mappings
Mapping for field myindex_type1:person_info.address.zip conflicts with: myindex_type2:person_info.address.zip. Check parameter: type

(Nemo) #7

Is there any way to fix this through code? I can delete the index type but not whole index. How can I remove one of the mapping?


(Yannick Welsch) #8

There is no other way than reindexing. This means creating a new index with proper mapping and reindexing all the documents, deleting your old index afterwards.


(Nemo) #9

That's gonna be pain since this is already deployed in multiple environment. I wish there was a way to convert all the improper data type to string globally if we don't care about aggregation.


(Mark Walkom) #10

There is, reindex :stuck_out_tongue:


(Nemo) #11

Not when I have TB's of data and minimal down time :slight_smile:


(system) #12