# Update mapping

**URL:** https://discuss.elastic.co/t/update-mapping/7517
**Category:** Elasticsearch
**Created:** [April 30, 2012, 11:08pm UTC](https://discuss.elastic.co/t/update-mapping/7517 "2012-04-30T23:08:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Gaurav\_Vijayvargiya](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@Gaurav\_Vijayvargiya](https://discuss.elastic.co/u/Gaurav_Vijayvargiya)
#### Post date: [April 30, 2012, 11:08pm UTC](https://discuss.elastic.co/t/update-mapping/7517/1 "2012-04-30T23:08:12Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 2, 2012, 4:18pm UTC](https://discuss.elastic.co/t/update-mapping/7517/2 "2012-05-02T16:18:00Z")

</div>

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](mailto: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](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

---

<div class="post-metadata">

### Author: ![Gaurav\_Vijayvargiya](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@Gaurav\_Vijayvargiya](https://discuss.elastic.co/u/Gaurav_Vijayvargiya)
#### Post date: [May 2, 2012, 4:43pm UTC](https://discuss.elastic.co/t/update-mapping/7517/3 "2012-05-02T16:43:44Z")

</div>

OK, makes sense. Thanks

Gaurav

On Wednesday, May 2, 2012 9:18:00 AM UTC-7, kimchy wrote:

> 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 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](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

---

<div class="post-metadata">

### Author: ![Frank\_LaRosa](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@Frank\_LaRosa](https://discuss.elastic.co/u/Frank_LaRosa)
#### Post date: [May 2, 2012, 10:18pm UTC](https://discuss.elastic.co/t/update-mapping/7517/4 "2012-05-02T22:18:19Z")

</div>

Does the stored mapping matter? Can I just specify a new mapping every time  
I add or update a document?

On Wednesday, May 2, 2012 11:18:00 AM UTC-5, kimchy wrote:

> 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](mailto: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](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

---

<div class="post-metadata">

### Author: ![Suraj\_Bhansali](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Suraj\_Bhansali](https://discuss.elastic.co/u/Suraj_Bhansali)
#### Post date: [March 14, 2013, 10:59am UTC](https://discuss.elastic.co/t/update-mapping/7517/5 "2013-03-14T10:59:53Z")

</div>

Hi,

I have created new index with mapping . Can you please let me know how to  
index the data. Here I have push data from couchbase to Elasticsearch.  
Also I have one question how to disable field in Elasticsearch which is  
not required to me?

Thanks in advance........

On Wednesday, 2 May 2012 21:48:00 UTC+5:30, kimchy wrote:

> 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 \<[gvijay...@gmail.com](mailto:gvijay...@gmail.com)\<javascript:\>
> 
> > 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](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

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:46am UTC](https://discuss.elastic.co/t/update-mapping/7517/6 "2017-07-06T02:46:29Z")

</div>


