# Disallow Dynamic mapping in ElasticSearch

**URL:** <https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995>\
**Category:** Elasticsearch\
**Created:** [June 27, 2016, 6:05am UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995 "2016-06-27T06:05:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramkchirra](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramkchirra](https://discuss.elastic.co/u/ramkchirra)\
**Post date:** [June 27, 2016, 6:05am UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995/1 "2016-06-27T06:05:10Z")

</div>

Hi,  
I have a Explicit mapping defined on Elasticsearch and i want to post data in the exact format (not allowing additional properties/fields ).

eg: I have the following template defined with name **biodata** which gets applied to indexes starting with test\*.

PUT /\_template/biodata  
{  
"template": "test\*",  
"settings": {  
"number\_of\_shards": 1  
},  
"mappings": {  
"address" : {  
"\_source": {  
"enabled": true  
},  
"properties": {  
"firstname": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"DOB": {  
"type": "date",  
"format": "dd/MM/yyyy HH:mm:ss"  
}  
}  
}  
}  
}

This mapping has type " **address**" which contains 2 properties " **firstname**" and " **DOB**". Now, i don't want Elasticsearch to accept the request which is like

POST /testindex/address/1  
{  
"firstname" : "SAMPLE FIRST NAME",  
"DOB" : "14/09/1980 00:00:00",  
"lastname" : "TEST LAST NAME",  
"contact" : 123456789  
}  
OR

POST /testindex/address/1  
{  
"DOB" : "14/09/1980 00:00:00"  
}

How can i achieve this? Please help

Thanks and Regards,  
RK

---

<div class="post-metadata">

**Author:** ![abeyad](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@abeyad](https://discuss.elastic.co/u/abeyad)\
**Post date:** [June 27, 2016, 5:51pm UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995/2 "2016-06-27T17:51:07Z")

</div>

You probably want to set the `dynamic` setting on the properties you don't want indexed to `false`. That will disallow unmapped fields from being accepted for indexing. See [https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html)

---

<div class="post-metadata">

**Author:** ![ramkchirra](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramkchirra](https://discuss.elastic.co/u/ramkchirra)\
**Post date:** [June 28, 2016, 7:27am UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995/3 "2016-06-28T07:27:55Z")

</div>

Thanks for the reply. I was able to get good info in the specified link.  
However, i have a scenario where in the above example, POST request with only "DOB" property should be rejected. I mean the POST request with subset of the specified properties should not be accepted. Elasticsearch should accept requests with only the exact properties specified in the index template.

Is there any setting to do that?

Thanks,  
RK

---

<div class="post-metadata">

**Author:** ![abeyad](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@abeyad](https://discuss.elastic.co/u/abeyad)\
**Post date:** [June 28, 2016, 7:36pm UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995/4 "2016-06-28T19:36:58Z")

</div>

Yes, then you want to specify `dynamic` as `strict`, see the same link for details

---

<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 5, 2017, 10:39pm UTC](https://discuss.elastic.co/t/disallow-dynamic-mapping-in-elasticsearch/53995/5 "2017-07-05T22:39:51Z")

</div>


