# Extend Mapping

**URL:** https://discuss.elastic.co/t/extend-mapping/9431
**Category:** Elasticsearch
**Created:** [October 20, 2012, 8:09pm UTC](https://discuss.elastic.co/t/extend-mapping/9431 "2012-10-20T20:09:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Jennewei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christopher_jennewei/32/2671_2.png) [@Christopher\_Jennewei](https://discuss.elastic.co/u/Christopher_Jennewei)
#### Post date: [October 20, 2012, 8:09pm UTC](https://discuss.elastic.co/t/extend-mapping/9431/1 "2012-10-20T20:09:35Z")

</div>

Hi, I'm new to ES and just joined a project that's been using it for  
awhile, so they have everything up and running. I'm now trying to extend  
the mapping of one of their indices, but having a hard time figuring how to  
do it and how to add a value for every index that already exists.

Here is a portion of the code that created their mapping:

curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
"mappings": {  
"user1" : {  
"\_all" : {"enabled" : false},  
"properties" : {  
"UserEmail" : {"type" : "string", "index" :  
"analyzed", "analyzer" : "keyword"},  
"Uid": {"type" : "string", "index" :  
"analyzed","analyzer" : "keyword"},  
"Name": {"type" : "string", "index" :  
"analyzed", "analyzer" : "standard"},  
"Location": {"type" : "string", "index" :  
"analyzed", "analyzer" : "standard"},  
"Description": {"type" : "string", "index"  
: "analyzed", "analyzer" : "snowball"},  
"Password" : {"type" : "string" }  
}  
}  
}  
}'

I just need to add one property: "Private" : {"type" : "boolean"}

I've tried running the above with my property included, but when I perform  
a search (curl -XGET '[http://localhost:9200/auuser1/user1/\_search](http://localhost:9200/auuser1/user1/_search)') it  
doesn't show my new property.

_How can I add my new property and set a default value for all existing  
entries?_

--

---

<div class="post-metadata">

### Author: ![Christopher\_Jennewei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christopher_jennewei/32/2671_2.png) [@Christopher\_Jennewei](https://discuss.elastic.co/u/Christopher_Jennewei)
#### Post date: [October 20, 2012, 11:45pm UTC](https://discuss.elastic.co/t/extend-mapping/9431/2 "2012-10-20T23:45:09Z")

</div>

And for future reference, is there a way to delete a property from the  
mapping?

On Saturday, October 20, 2012 1:09:35 PM UTC-7, Christopher Jennewein wrote:

> Hi, I'm new to ES and just joined a project that's been using it for  
> awhile, so they have everything up and running. I'm now trying to extend  
> the mapping of one of their indices, but having a hard time figuring how to  
> do it and how to add a value for every index that already exists.
> 
> Here is a portion of the code that created their mapping:
> 
> curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
> "mappings": {  
> "user1" : {  
> "\_all" : {"enabled" : false},  
> "properties" : {  
> "UserEmail" : {"type" : "string", "index"  
> : "analyzed", "analyzer" : "keyword"},  
> "Uid": {"type" : "string", "index" :  
> "analyzed","analyzer" : "keyword"},  
> "Name": {"type" : "string", "index" :  
> "analyzed", "analyzer" : "standard"},  
> "Location": {"type" : "string", "index" :  
> "analyzed", "analyzer" : "standard"},  
> "Description": {"type" : "string", "index"  
> : "analyzed", "analyzer" : "snowball"},  
> "Password" : {"type" : "string" }  
> }  
> }  
> }  
> }'
> 
> I just need to add one property: "Private" : {"type" : "boolean"}
> 
> I've tried running the above with my property included, but when I perform  
> a search (curl -XGET '[http://localhost:9200/auuser1/user1/\_search](http://localhost:9200/auuser1/user1/_search)') it  
> doesn't show my new property.
> 
> _How can I add my new property and set a default value for all existing  
> entries?_

--

---

<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: [October 21, 2012, 1:17am UTC](https://discuss.elastic.co/t/extend-mapping/9431/3 "2012-10-21T01:17:24Z")

</div>

No, you can't delete a property from a mapping.

On Oct 21, 2012, at 1:45 AM, Christopher Jennewein [christopher.jennewein@gmail.com](mailto:christopher.jennewein@gmail.com) wrote:

> And for future reference, is there a way to delete a property from the mapping?
> 
> On Saturday, October 20, 2012 1:09:35 PM UTC-7, Christopher Jennewein wrote:  
> Hi, I'm new to ES and just joined a project that's been using it for awhile, so they have everything up and running. I'm now trying to extend the mapping of one of their indices, but having a hard time figuring how to do it and how to add a value for every index that already exists.
> 
> Here is a portion of the code that created their mapping:
> 
> curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
> "mappings": {  
> "user1" : {  
> "\_all" : {"enabled" : false},  
> "properties" : {  
> "UserEmail" : {"type" : "string", "index" : "analyzed", "analyzer" : "keyword"},  
> "Uid": {"type" : "string", "index" : "analyzed","analyzer" : "keyword"},  
> "Name": {"type" : "string", "index" : "analyzed", "analyzer" : "standard"},  
> "Location": {"type" : "string", "index" : "analyzed", "analyzer" : "standard"},  
> "Description": {"type" : "string", "index" : "analyzed", "analyzer" : "snowball"},  
> "Password" : {"type" : "string" }  
> }  
> }  
> }  
> }'
> 
> I just need to add one property: "Private" : {"type" : "boolean"}
> 
> I've tried running the above with my property included, but when I perform a search (curl -XGET '[http://localhost:9200/auuser1/user1/\_search](http://localhost:9200/auuser1/user1/_search)') it doesn't show my new property.
> 
> How can I add my new property and set a default value for all existing entries?
> 
> --

--

---

<div class="post-metadata">

### Author: ![Christopher\_Jennewei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christopher_jennewei/32/2671_2.png) [@Christopher\_Jennewei](https://discuss.elastic.co/u/Christopher_Jennewei)
#### Post date: [October 22, 2012, 2:02am UTC](https://discuss.elastic.co/t/extend-mapping/9431/4 "2012-10-22T02:02:39Z")

</div>

How do I add properties to a mapping and add values to pre-existing items?

On Saturday, October 20, 2012 6:17:25 PM UTC-7, kimchy wrote:

> No, you can't delete a property from a mapping.
> 
> On Oct 21, 2012, at 1:45 AM, Christopher Jennewein \<  
> [christophe...@gmail.com](mailto:christophe...@gmail.com) \<javascript:\>\> wrote:
> 
> And for future reference, is there a way to delete a property from the  
> mapping?
> 
> On Saturday, October 20, 2012 1:09:35 PM UTC-7, Christopher Jennewein  
> wrote:
> 
> > Hi, I'm new to ES and just joined a project that's been using it for  
> > awhile, so they have everything up and running. I'm now trying to extend  
> > the mapping of one of their indices, but having a hard time figuring how to  
> > do it and how to add a value for every index that already exists.
> > 
> > Here is a portion of the code that created their mapping:
> > 
> > curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
> > "mappings": {  
> > "user1" : {  
> > "\_all" : {"enabled" : false},  
> > "properties" : {  
> > "UserEmail" : {"type" : "string", "index"  
> > : "analyzed", "analyzer" : "keyword"},  
> > "Uid": {"type" : "string", "index" :  
> > "analyzed","analyzer" : "keyword"},  
> > "Name": {"type" : "string", "index" :  
> > "analyzed", "analyzer" : "standard"},  
> > "Location": {"type" : "string", "index" :  
> > "analyzed", "analyzer" : "standard"},  
> > "Description": {"type" : "string",  
> > "index" : "analyzed", "analyzer" : "snowball"},  
> > "Password" : {"type" : "string" }  
> > }  
> > }  
> > }  
> > }'
> > 
> > I just need to add one property: "Private" : {"type" : "boolean"}
> > 
> > I've tried running the above with my property included, but when I  
> > perform a search (curl -XGET '[http://localhost:9200/auuser1/user1/\_search](http://localhost:9200/auuser1/user1/_search)')  
> > it doesn't show my new property.
> > 
> > _How can I add my new property and set a default value for all existing  
> > entries?_
> 
> --

--

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [October 22, 2012, 5:23pm UTC](https://discuss.elastic.co/t/extend-mapping/9431/5 "2012-10-22T17:23:32Z")

</div>

Christopher,

I don't think that the code that you posted here actually creates any  
mappings. When you are creating mapping without creating an index the root  
"mappings" element is not needed.

To add a property, you can repost the new mapping that includes properties  
that you need:

curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
"user1" : {  
"\_all" : {"enabled" : false},  
"properties" : {  
"UserEmail" : {"type" : "string", "index" : "analyzed",  
"analyzer" : "keyword"},  
"Uid": {"type" : "string", "index" : "analyzed","analyzer" :  
"keyword"},  
"Name": {"type" : "string", "index" : "analyzed", "analyzer" :  
"standard"},  
"Location": {"type" : "string", "index" : "analyzed",  
"analyzer" : "standard"},  
"Description": {"type" : "string", "index" : "analyzed",  
"analyzer" : "snowball"},  
"Password" : {"type" : "string" },  
"Private" : {"type" : "boolean" }  
}  
}  
}'

Or just post mapping with new elements:

curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
"user1" : {  
"\_all" : {"enabled" : false},  
"properties" : {  
"Private" : {"type" : "boolean" }  
}  
}  
}'

In both cases elasticsearch will try to merge the new mapping with existing  
mapping, and since it cannot delete existing properties, it will only add  
the new properties to the mapping.

On Sunday, October 21, 2012 10:02:39 PM UTC-4, Christopher Jennewein wrote:

> How do I add properties to a mapping and add values to pre-existing items?
> 
> On Saturday, October 20, 2012 6:17:25 PM UTC-7, kimchy wrote:
> 
> > No, you can't delete a property from a mapping.
> > 
> > On Oct 21, 2012, at 1:45 AM, Christopher Jennewein \<  
> > [christophe...@gmail.com](mailto:christophe...@gmail.com)\> wrote:
> > 
> > And for future reference, is there a way to delete a property from the  
> > mapping?
> > 
> > On Saturday, October 20, 2012 1:09:35 PM UTC-7, Christopher Jennewein  
> > wrote:
> > 
> > > Hi, I'm new to ES and just joined a project that's been using it for  
> > > awhile, so they have everything up and running. I'm now trying to extend  
> > > the mapping of one of their indices, but having a hard time figuring how to  
> > > do it and how to add a value for every index that already exists.
> > > 
> > > Here is a portion of the code that created their mapping:
> > > 
> > > curl -XPUT '[http://localhost:9200/auuser1/user1/\_mapping](http://localhost:9200/auuser1/user1/_mapping)' -d '{  
> > > "mappings": {  
> > > "user1" : {  
> > > "\_all" : {"enabled" : false},  
> > > "properties" : {  
> > > "UserEmail" : {"type" : "string",  
> > > "index" : "analyzed", "analyzer" : "keyword"},  
> > > "Uid": {"type" : "string", "index" :  
> > > "analyzed","analyzer" : "keyword"},  
> > > "Name": {"type" : "string", "index" :  
> > > "analyzed", "analyzer" : "standard"},  
> > > "Location": {"type" : "string", "index"  
> > > : "analyzed", "analyzer" : "standard"},  
> > > "Description": {"type" : "string",  
> > > "index" : "analyzed", "analyzer" : "snowball"},  
> > > "Password" : {"type" : "string" }  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > I just need to add one property: "Private" : {"type" : "boolean"}
> > > 
> > > I've tried running the above with my property included, but when I  
> > > perform a search (curl -XGET '  
> > > [http://localhost:9200/auuser1/user1/\_search](http://localhost:9200/auuser1/user1/_search)') it doesn't show my new  
> > > property.
> > > 
> > > _How can I add my new property and set a default value for all existing  
> > > entries?_
> > 
> > --

--

---

<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:07am UTC](https://discuss.elastic.co/t/extend-mapping/9431/6 "2017-07-06T03:07:33Z")

</div>


