# How to create dynamic template for nested objects

**URL:** <https://discuss.elastic.co/t/how-to-create-dynamic-template-for-nested-objects/187310>\
**Category:** Elasticsearch\
**Created:** [June 25, 2019, 10:58am UTC](https://discuss.elastic.co/t/how-to-create-dynamic-template-for-nested-objects/187310 "2019-06-25T10:58:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muthualagappan](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@muthualagappan](https://discuss.elastic.co/u/muthualagappan)\
**Post date:** [June 25, 2019, 10:58am UTC](https://discuss.elastic.co/t/how-to-create-dynamic-template-for-nested-objects/187310/1 "2019-06-25T10:58:34Z")

</div>

I want to create a dynamic template for mapping the array of objects as nested type instead of object type automatically.

I have downloaded the basic template from curl -X GET "localhost:9200/\_template". Please let me know where should I to change the type as nested for array of objects.

Please let me know if you require more details

---

<div class="post-metadata">

**Author:** ![muthualagappan](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@muthualagappan](https://discuss.elastic.co/u/muthualagappan)\
**Post date:** [July 5, 2019, 4:14am UTC](https://discuss.elastic.co/t/how-to-create-dynamic-template-for-nested-objects/187310/2 "2019-07-05T04:14:48Z")

</div>

Found the solution for this

{  
"mappings" : {  
"dynamic\_templates": [  
{  
"objects": {  
"match": "\*",  
"match\_mapping\_type" : "object",  
"mapping": {  
"type": "nested",  
}  
}  
}  
]  
}  
}

---

<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:** [August 2, 2019, 4:14am UTC](https://discuss.elastic.co/t/how-to-create-dynamic-template-for-nested-objects/187310/3 "2019-08-02T04:14:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
