Update mapping

You can't change existing mapping type, you need to create a new index with
the correct mapping and index the data again.

On Tue, May 1, 2012 at 2:08 AM, Gaurav Vijayvargiya <gvijayvargiya@gmail.com

wrote:

Hi

I have mapping with 'lat' and 'lon' defined as double

"location" : {
"dynamic" : "true",
"properties" : {
...
...
"lon_lat" : {
"dynamic" : "true",
"properties" : {
"lon" : {
"type" : "double"
},
"lat" : {
"type" : "double"
}
}
},
...

I want to make the type of "lon_lat"

"location" : {
"properties" : {
"lon_lat" : { "type" : "geo_point"}
}
},

I get error when I try to update the mapping
{"error":"MergeMappingException[Merge failed with failures {[Can't
merge a non object mapping [lon_lat] with an object mapping
[lon_lat]]}]","status":400}

Reading previous posts, looks like this is expected. And one of the
solutions proposed is to recreate the index with new mapping.

In my case though, there are no existing records with "lon_lat"

curl -XPOST 'http://localhost:9200/test/test/_search?pretty=true' -d
' { "filter" : { "exists" : { "field" : "location.lon_lat" } } }'
{
"took" : 28,
"timed_out" : false,
"_shards" : {
"total" : 20,
"successful" : 20,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}

Does it make anything easier for me? Or do I still need to recreate
the index?

What is the best way to build the new index while keeping it in sync
with the existing index in production environment?

Thanks
Gaurav