# Dynamic mapping for index

**URL:** <https://discuss.elastic.co/t/dynamic-mapping-for-index/15940>\
**Category:** Elasticsearch\
**Created:** [February 21, 2014, 5:24am UTC](https://discuss.elastic.co/t/dynamic-mapping-for-index/15940 "2014-02-21T05:24:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![golchhamohit](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@golchhamohit](https://discuss.elastic.co/u/golchhamohit)\
**Post date:** [February 21, 2014, 5:24am UTC](https://discuss.elastic.co/t/dynamic-mapping-for-index/15940/1 "2014-02-21T05:24:22Z")

</div>

Hi all,

```
      I am new to Elastic Search and I had a use case which needs to 

```

create a mapping dynamically on addition of an index.  
I heard about dynamic templates and read some about it, all examples given  
are regarding mapping dynamically added fields.  
Is the same possible for index ?. Also, the index for which I want to  
dynamically create mapping is of two digit and the type  
is also of two digit. Is it possible to restrict the templates only to  
those specifications. Can you provide with a simple example  
of how to create a template with any simple mapping that applies to all  
indices and types with 2 digits ?

Thanks & Regards,  
Mohit Golchha

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c4563bd0-6bc8-4178-9a69-ad4e62ca3bf3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c4563bd0-6bc8-4178-9a69-ad4e62ca3bf3%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 21, 2014, 1:20pm UTC](https://discuss.elastic.co/t/dynamic-mapping-for-index/15940/2 "2014-02-21T13:20:03Z")

</div>

Yes, you can read more about index templates here:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html)

You can use a name pattern to match what indexes to apply the template to.  
You can also define dynamic templates:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#\_dynamic\_templates](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates)

To match field names, or types. I don't think you can do something like  
match only if the value is 2 digits.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e099f321-fd02-4509-9375-6aa2a378e23a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e099f321-fd02-4509-9375-6aa2a378e23a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:48am UTC](https://discuss.elastic.co/t/dynamic-mapping-for-index/15940/3 "2017-07-06T01:48:23Z")

</div>


