# Dynamic mapping overrides fields?

**URL:** <https://discuss.elastic.co/t/dynamic-mapping-overrides-fields/8378>\
**Category:** Elasticsearch\
**Created:** [July 10, 2012, 4:23pm UTC](https://discuss.elastic.co/t/dynamic-mapping-overrides-fields/8378 "2012-07-10T16:23:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipDS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philipds/32/2817_2.png) [@philipDS](https://discuss.elastic.co/u/philipDS)\
**Post date:** [July 10, 2012, 4:23pm UTC](https://discuss.elastic.co/t/dynamic-mapping-overrides-fields/8378/1 "2012-07-10T16:23:51Z")

</div>

Hey,

I set a mapping as follows:

curl -XPUT '[http://localhost:9200/my\_index/my\_type/\_mapping](http://localhost:9200/my_index/my_type/_mapping)' -d '  
{  
"my\_type" : {  
contacts: {  
properties: {  
user: { type: 'String', index: 'not\_analyzed' },  
source : { type: 'String', index: 'not\_analyzed' },  
type : { type: 'String', index: 'not\_analyzed' },  
user\_id : { type: 'String', index: 'not\_analyzed' },  
profile\_url : { type: 'String', index: 'not\_analyzed' },  
first\_name : { type: 'String', index: 'not\_analyzed' },  
last\_name : { type: 'String', index: 'not\_analyzed' },  
headline : { type: 'String', analyzer: 'lowercase\_keyword'  
},  
industry : { type: 'String', index: 'not\_analyzed' },  
location : { type: 'String', analyzer: 'lowercase\_keyword'  
},  
picture\_url : { type: 'String', index: 'not\_analyzed' },  
twitter : {  
"dynamic": false,  
properties : {  
handle : { type: 'String', index: 'not\_analyzed' },  
tweet : { type: 'String', index: 'not\_analyzed' },  
age : { type: 'Date', index: 'not\_analyzed' }  
}  
},  
extra\_info : {  
"dynamic": false,  
properties : {  
topics : { type: 'String', index: 'not\_analyzed' },  
age : { type: 'Date', index: 'not\_analyzed' }  
}  
},  
skills : { type: 'String', index\_name: 'skill', index:  
'not\_analyzed' },  
positions : {  
properties : {  
company : {  
properties: {  
industry : { type: 'String', index:  
'not\_analyzed' },  
name : { type: 'String', index:  
'not\_analyzed' },  
type: 'nested'  
//type : { type: 'String', index:  
'not\_analyzed' }  
},  
type: 'nested'  
},  
isCurrent : { type: 'boolean' },  
startDate : {  
properties: {  
month: { type: 'long', index:  
'not\_analyzed' },  
year: { type: 'long', index: 'not\_analyzed'  
}  
}  
},  
summary : { type: 'String', index: 'not\_analyzed' },  
title : { type: 'String', index: 'not\_analyzed' }  
},  
type: 'nested'  
},  
tags : { type: 'String', index: 'not\_analyzed' },  
dismissTime : { type: 'Date' },  
dateIndexed : { type: 'Date' }  
}  
}  
}'

Note that I set the twitter and extra\_info fields (type object?) to  
'dynamic: false'. Then I index a bunch of documents, and my ES console  
outputs the following: [Power, Alex] [my\_index] update\_mapping [my\_type]  
(dynamic). This is ok I guess, since I didn't disable the dynamic field on  
the overall root object. However, when I GET my mapping using a CURL then,  
I see the following mapping for twitter and extra\_info:

"twitter" : {  
"type" : "object",  
"dynamic" : "true"  
},  
"extra\_info" : {  
"type" : "object",  
"dynamic" : "true"  
},  
...

Is there an explanation for this? How can I disable the dynamic field or  
make it 'strict'? I have tried setting the overall object to dynamic: false  
too, but this didn't help. Anyone knows why this keeps on happening? Thanks!

---

<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:** [July 10, 2012, 5:35pm UTC](https://discuss.elastic.co/t/dynamic-mapping-overrides-fields/8378/2 "2012-07-10T17:35:37Z")

</div>

I don't think your mapping is getting applied. There are several issues  
with the mapping command in your email including use of apostrophes,  
comments in json and missing "properties" between "my\_type" and "contacts".

On Tuesday, July 10, 2012 12:23:51 PM UTC-4, philipDS wrote:

> Hey,
> 
> I set a mapping as follows:
> 
> curl -XPUT '[http://localhost:9200/my\_index/my\_type/\_mapping](http://localhost:9200/my_index/my_type/_mapping)' -d '  
> {  
> "my\_type" : {  
> contacts: {  
> properties: {  
> user: { type: 'String', index: 'not\_analyzed' },  
> source : { type: 'String', index: 'not\_analyzed' },  
> type : { type: 'String', index: 'not\_analyzed' },  
> user\_id : { type: 'String', index: 'not\_analyzed' },  
> profile\_url : { type: 'String', index: 'not\_analyzed' },  
> first\_name : { type: 'String', index: 'not\_analyzed' },  
> last\_name : { type: 'String', index: 'not\_analyzed' },  
> headline : { type: 'String', analyzer: 'lowercase\_keyword'  
> },  
> industry : { type: 'String', index: 'not\_analyzed' },  
> location : { type: 'String', analyzer: 'lowercase\_keyword'  
> },  
> picture\_url : { type: 'String', index: 'not\_analyzed' },  
> twitter : {  
> "dynamic": false,  
> properties : {  
> handle : { type: 'String', index: 'not\_analyzed' },  
> tweet : { type: 'String', index: 'not\_analyzed' },  
> age : { type: 'Date', index: 'not\_analyzed' }  
> }  
> },  
> extra\_info : {  
> "dynamic": false,  
> properties : {  
> topics : { type: 'String', index: 'not\_analyzed' },  
> age : { type: 'Date', index: 'not\_analyzed' }  
> }  
> },  
> skills : { type: 'String', index\_name: 'skill', index:  
> 'not\_analyzed' },  
> positions : {  
> properties : {  
> company : {  
> properties: {  
> industry : { type: 'String', index:  
> 'not\_analyzed' },  
> name : { type: 'String', index:  
> 'not\_analyzed' },  
> type: 'nested'  
> //type : { type: 'String', index:  
> 'not\_analyzed' }  
> },  
> type: 'nested'  
> },  
> isCurrent : { type: 'boolean' },  
> startDate : {  
> properties: {  
> month: { type: 'long', index:  
> 'not\_analyzed' },  
> year: { type: 'long', index:  
> 'not\_analyzed' }  
> }  
> },  
> summary : { type: 'String', index: 'not\_analyzed'  
> },  
> title : { type: 'String', index: 'not\_analyzed' }  
> },  
> type: 'nested'  
> },  
> tags : { type: 'String', index: 'not\_analyzed' },  
> dismissTime : { type: 'Date' },  
> dateIndexed : { type: 'Date' }  
> }  
> }  
> }'
> 
> Note that I set the twitter and extra\_info fields (type object?) to  
> 'dynamic: false'. Then I index a bunch of documents, and my ES console  
> outputs the following: [Power, Alex] [my\_index] update\_mapping [my\_type]  
> (dynamic). This is ok I guess, since I didn't disable the dynamic field on  
> the overall root object. However, when I GET my mapping using a CURL then,  
> I see the following mapping for twitter and extra\_info:
> 
> "twitter" : {  
> "type" : "object",  
> "dynamic" : "true"  
> },  
> "extra\_info" : {  
> "type" : "object",  
> "dynamic" : "true"  
> },  
> ...
> 
> Is there an explanation for this? How can I disable the dynamic field or  
> make it 'strict'? I have tried setting the overall object to dynamic: false  
> too, but this didn't help. Anyone knows why this keeps on happening? Thanks!

---

<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:20am UTC](https://discuss.elastic.co/t/dynamic-mapping-overrides-fields/8378/3 "2017-07-06T03:20:41Z")

</div>


