# How to define mapping in runtime

**URL:** <https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728>\
**Category:** Elasticsearch\
**Created:** [October 11, 2016, 3:16pm UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728 "2016-10-11T15:16:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreeram](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sreeram](https://discuss.elastic.co/u/sreeram)\
**Post date:** [October 11, 2016, 3:16pm UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728/1 "2016-10-11T15:16:39Z")

</div>

Hi,

I'm using Elasticsearch 2.3.4 & [Elasticsearch.Net](http://Elasticsearch.Net) (Low-level client) SDK for indexing JSON documents which are dynamic in nature.

I want to create mapping for my JSON structure before indexing documents in order to avoid field type getting detected (numeric\_detection & date\_detection = True) wrongly while inserting the first document.

How to PUT below mapping (JSON) through [Elasticsearch.Net](http://Elasticsearch.Net) Or NEST SDK API?!  
PUT my\_index  
{  
"mappings": {  
"user": {  
"\_all": { "enabled": false },  
"properties": {  
"title": { "type": "string" },  
"name": { "type": "string" },  
"age": { "type": "integer" }  
}  
},  
"blogpost": {  
"properties": {  
"title": { "type": "string" },  
"body": { "type": "string" },  
"user\_id": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"created": {  
"type": "date",  
"format": "strict\_date\_optional\_time||epoch\_millis"  
}  
}  
}  
}  
}

Regards,  
Sreeram

---

<div class="post-metadata">

**Author:** ![sreeram](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sreeram](https://discuss.elastic.co/u/sreeram)\
**Post date:** [October 12, 2016, 7:17am UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728/2 "2016-10-12T07:17:16Z")

</div>

Someone help me out. Is there anyway to do this ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 12, 2016, 7:33am UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728/3 "2016-10-12T07:33:59Z")

</div>

Does [Create index | Elasticsearch.Net and NEST: the .NET clients [1.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/net-api/1.x/create-indices.html) help? Which version of the libraries are you using?

> Someone help me out. Is there anyway to do this ?

Be patient.

---

<div class="post-metadata">

**Author:** ![sreeram](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sreeram](https://discuss.elastic.co/u/sreeram)\
**Post date:** [October 12, 2016, 7:49am UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728/4 "2016-10-12T07:49:03Z")

</div>

Thanks for your response. I'll Check and update.

---

<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:13pm UTC](https://discuss.elastic.co/t/how-to-define-mapping-in-runtime/62728/5 "2017-07-05T22:13:08Z")

</div>


