# Update mapping

**URL:** <https://discuss.elastic.co/t/update-mapping/7543>\
**Category:** Elasticsearch\
**Created:** [May 2, 2012, 8:52pm UTC](https://discuss.elastic.co/t/update-mapping/7543 "2012-05-02T20:52:43Z")\
**Posts on this page:** 7\
**Page:** 1

<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, 8:52pm UTC](https://discuss.elastic.co/t/update-mapping/7543/1 "2012-05-02T20:52:43Z")

</div>

Hi,

I'm trying to update a mapping via the Java API. The code appears to  
work, however, when I get the mapping it hasn't changed.

Here is what my code looks like:

```
IndicesAdminClient admin = client.admin().indices();
PutMappingRequest putRequest = new PutMappingRequest(INDEX_NAME);
putRequest.source(mapping());
putRequest.type("_default_");
putRequest.ignoreConflicts(true);
PutMappingResponse response =

```

admin.putMapping(putRequest).actionGet(30000);  
if (response.acknowledged())  
log.info("putMapping succeeded");

Note that the funciton "mapping()" returns my mapping as an  
XContentBuilder object, including the new fields and other changes I  
am trying to make.

This code runs and prints the success message, but when I query the  
mapping from the command line, I get the old mapping. What am I doing  
wrong?

---

<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 4, 2012, 1:11pm UTC](https://discuss.elastic.co/t/update-mapping/7543/2 "2012-05-04T13:11:51Z")

</div>

You are updating the _default_ mapping, are you saying that when you update  
it and then do a get, you don't get it? Can you gist a curl recreation?

On Wed, May 2, 2012 at 11:52 PM, Frank LaRosa [frank@studyblue.com](mailto:frank@studyblue.com) wrote:

> Hi,
> 
> I'm trying to update a mapping via the Java API. The code appears to  
> work, however, when I get the mapping it hasn't changed.
> 
> Here is what my code looks like:
> 
> ```
> IndicesAdminClient admin = client.admin().indices();
> PutMappingRequest putRequest = new PutMappingRequest(INDEX_NAME);
> putRequest.source(mapping());
> putRequest.type("_default_");
> putRequest.ignoreConflicts(true);
> PutMappingResponse response =
> 
> ```
> 
> admin.putMapping(putRequest).actionGet(30000);  
> if (response.acknowledged())  
> log.info("putMapping succeeded");
> 
> Note that the funciton "mapping()" returns my mapping as an  
> XContentBuilder object, including the new fields and other changes I  
> am trying to make.
> 
> This code runs and prints the success message, but when I query the  
> mapping from the command line, I get the old mapping. What am I doing  
> wrong?

---

<div class="post-metadata">

**Author:** ![feridcelik](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@feridcelik](https://discuss.elastic.co/u/feridcelik)\
**Post date:** [May 27, 2012, 3:45pm UTC](https://discuss.elastic.co/t/update-mapping/7543/3 "2012-05-27T15:45:50Z")

</div>

I got the same issue with java api 0.19.4, and also with 0.19.3.

Putting new mappings work, but cant update. Code doesnt throw any exception or something.

PutMappingRequestBuilder rq = client.admin().indices().preparePutMapping("someIndex");  
rq.setType("xxxx").setSource(TYPE\_MAPPING\_SOURCE);  
rq.setIgnoreConflicts(true);

initial mapping source(TYPE\_MAPPING\_SOURCE) is something like this:  
{  
"xxxx" : {  
"properties" : {  
"someText" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}

and im trying to update it to:  
{  
"xxxx" : {  
"properties" : {  
"someText" : {  
"type" : "string",  
"index" : "no"  
}  
}  
}  
}

I also tried closing index before trying to update, but it doesnt work too.

When i set ignoreConflicts,  
rq.setIgnoreConflicts(false);

api throws an exception  
org.elasticsearch.index.mapper.MergeMappingException: Merge failed with failures {[mapper [someText] has different index values]}

Ferid Gürbüz

---

<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 30, 2012, 8:55am UTC](https://discuss.elastic.co/t/update-mapping/7543/4 "2012-05-30T08:55:20Z")

</div>

You can't change the index mapping setting of a field.

On Sun, May 27, 2012 at 5:45 PM, feridcelik [feridcelik@gmail.com](mailto:feridcelik@gmail.com) wrote:

> I got the same issue with java api 0.19.4, and also with 0.19.3.
> 
> Putting new mappings work, but cant update. Code doesnt throw any exception  
> or something.
> 
> PutMappingRequestBuilder rq =  
> client.admin().indices().preparePutMapping("someIndex");  
> rq.setType("xxxx").setSource(TYPE\_MAPPING\_SOURCE);  
> rq.setIgnoreConflicts(true);
> 
> initial mapping source(TYPE\_MAPPING\_SOURCE) is something like this:  
> {  
> "xxxx" : {  
> "properties" : {  
> "someText" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> }
> 
> and im trying to update it to:  
> {  
> "xxxx" : {  
> "properties" : {  
> "someText" : {  
> "type" : "string",  
> "index" : "no"  
> }  
> }  
> }  
> }
> 
> I also tried closing index before trying to update, but it doesnt work too.
> 
> When i set ignoreConflicts,  
> rq.setIgnoreConflicts(false);
> 
> api throws an exception  
> org.elasticsearch.index.mapper.MergeMappingException: Merge failed with  
> failures {[mapper [someText] has different index values]}
> 
> Ferid Gürbüz
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html](http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [May 30, 2012, 2:50pm UTC](https://discuss.elastic.co/t/update-mapping/7543/5 "2012-05-30T14:50:19Z")

</div>

As far as I know if a mapping is already defined for the index/document  
type, you can't change any of the following setting of a field: core type,  
index, store, term\_vector, index\_analyzer or search\_analyzer

-- Tanguy  
Twitter: @tlrx

Le dimanche 27 mai 2012 17:45:50 UTC+2, ferid çelik a écrit :

> I got the same issue with java api 0.19.4, and also with 0.19.3.
> 
> Putting new mappings work, but cant update. Code doesnt throw any  
> exception  
> or something.
> 
> PutMappingRequestBuilder rq =  
> client.admin().indices().preparePutMapping("someIndex");  
> rq.setType("xxxx").setSource(TYPE\_MAPPING\_SOURCE);  
> rq.setIgnoreConflicts(true);
> 
> initial mapping source(TYPE\_MAPPING\_SOURCE) is something like this:  
> {  
> "xxxx" : {  
> "properties" : {  
> "someText" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> }  
> }  
> }  
> }
> 
> and im trying to update it to:  
> {  
> "xxxx" : {  
> "properties" : {  
> "someText" : {  
> "type" : "string",  
> "index" : "no"  
> }  
> }  
> }  
> }
> 
> I also tried closing index before trying to update, but it doesnt work  
> too.
> 
> When i set ignoreConflicts,  
> rq.setIgnoreConflicts(false);
> 
> api throws an exception  
> org.elasticsearch.index.mapper.MergeMappingException: Merge failed with  
> failures {[mapper [someText] has different index values]}
> 
> Ferid Gürbüz
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html](http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![ajasuja18](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@ajasuja18](https://discuss.elastic.co/u/ajasuja18)\
**Post date:** [August 14, 2012, 6:48pm UTC](https://discuss.elastic.co/t/update-mapping/7543/6 "2012-08-14T18:48:27Z")

</div>

Hi Shay,

Can we change from dynamic:false to dynamic:true in case of custom mapping?

Also it would be useful to know what all can we change in the mapping  
which doesn't require the re-indexing of the older data?

Thanks in advance..!!

On Wednesday, May 30, 2012 1:55:20 AM UTC-7, kimchy wrote:

> You can't change the index mapping setting of a field.
> 
> On Sun, May 27, 2012 at 5:45 PM, feridcelik \<[ferid...@gmail.com](mailto:ferid...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I got the same issue with java api 0.19.4, and also with 0.19.3.
> > 
> > Putting new mappings work, but cant update. Code doesnt throw any  
> > exception  
> > or something.
> > 
> > PutMappingRequestBuilder rq =  
> > client.admin().indices().preparePutMapping("someIndex");  
> > rq.setType("xxxx").setSource(TYPE\_MAPPING\_SOURCE);  
> > rq.setIgnoreConflicts(true);
> > 
> > initial mapping source(TYPE\_MAPPING\_SOURCE) is something like this:  
> > {  
> > "xxxx" : {  
> > "properties" : {  
> > "someText" : {  
> > "type" : "string",  
> > "index" : "not\_analyzed"  
> > }  
> > }  
> > }  
> > }
> > 
> > and im trying to update it to:  
> > {  
> > "xxxx" : {  
> > "properties" : {  
> > "someText" : {  
> > "type" : "string",  
> > "index" : "no"  
> > }  
> > }  
> > }  
> > }
> > 
> > I also tried closing index before trying to update, but it doesnt work  
> > too.
> > 
> > When i set ignoreConflicts,  
> > rq.setIgnoreConflicts(false);
> > 
> > api throws an exception  
> > org.elasticsearch.index.mapper.MergeMappingException: Merge failed with  
> > failures {[mapper [someText] has different index values]}
> > 
> > Ferid Gürbüz
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html](http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-tp3957288p4018140.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--

---

<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, 3:16am UTC](https://discuss.elastic.co/t/update-mapping/7543/7 "2017-07-06T03:16:22Z")

</div>


