Deleting part of mapping in Elasticsearch 1.7

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,

Once mapping have created , can not be modified manually

1 Like

Thank you.

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

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

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

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?

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.

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.

There is, reindex :stuck_out_tongue:

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