# Type definition in a mapping file

**URL:** <https://discuss.elastic.co/t/type-definition-in-a-mapping-file/43046>\
**Category:** Elasticsearch\
**Created:** [February 29, 2016, 8:38pm UTC](https://discuss.elastic.co/t/type-definition-in-a-mapping-file/43046 "2016-02-29T20:38:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajitshrivastav](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajitshrivastav](https://discuss.elastic.co/u/ajitshrivastav)\
**Post date:** [February 29, 2016, 8:38pm UTC](https://discuss.elastic.co/t/type-definition-in-a-mapping-file/43046/1 "2016-02-29T20:38:17Z")

</div>

If there is a requirement to have a composite structure (hierarchical) in payload, is there a way to define mapping type.

Example payload :-

{  
"employee" : {  
"firstName" : "Ajit",  
"lastName" : "Shrivastav",  
"manager" : {  
"firstName" : "1stManager fName",  
"lastName" : "1stManager lName",  
"manager" : {  
"firstName" : "2ndManager fName",  
"lastName" : "2ndManager lName",  
"manager" : null  
}  
}  
}  
}

"manager" is of type "person",  
Mapping would like :-  
{  
"person": {  
"properties": {  
"firstName" : { "type" : "string", "index": "not\_analyzed" },  
"lastName" : { "type" : "string", "index": "not\_analyzed" },  
"manager" : {// here need to reuse the "person" type  
}  
}  
}  
}

So, the question is - Is there a way to define a type in mapping document and reuse them?

-Ajit

---

<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:** [February 29, 2016, 8:44pm UTC](https://discuss.elastic.co/t/type-definition-in-a-mapping-file/43046/2 "2016-02-29T20:44:24Z")

</div>

No, that's not possible in the index template format itself. You'd have to use a template or macro processor.

---

<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, 11:12pm UTC](https://discuss.elastic.co/t/type-definition-in-a-mapping-file/43046/3 "2017-07-05T23:12:46Z")

</div>

Closed on July 5, 2017, 11:12pm UTC


