# How to create a child type when its parent type is already exist in Elasticsearch 2.X?

**URL:** https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114
**Category:** Elasticsearch
**Created:** [April 22, 2016, 3:08am UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114 "2016-04-22T03:08:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![yuemaoxing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuemaoxing/32/41118_2.png) [@yuemaoxing](https://discuss.elastic.co/u/yuemaoxing)
#### Post date: [April 22, 2016, 3:08am UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/1 "2016-04-22T03:08:08Z")

</div>

I know parent/child has been rewritten in ES2.X, and the mapping for the parent type can be added at the same time as the mapping for the child type, but cannot be added before the child type.

But I think it's not logical. In my situation, I cannot create all children types with their parent type mapping at the same time. I really need to create a child type when its parent type is already exist.

Please give some suggestions.

---

<div class="post-metadata">

### Author: ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)
#### Post date: [April 22, 2016, 8:53am UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/2 "2016-04-22T08:53:03Z")

</div>

There is no workaround for this at the moment. If you want to add a new child mapping pointing to an existing parent mapping then you need to reindex. (the reindex api can make this a bit easier)

I think maybe ES can relax this constraint a bit. Just to understand your use case correctly: you only introduce new child mappings that point to a parent mapping that already has other child mappings? If so then I think this maybe can be allowed.

What ES can't support is adding child mappings that point to a parent mapping that has no other child mappings yet.

---

<div class="post-metadata">

### Author: ![yuemaoxing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuemaoxing/32/41118_2.png) [@yuemaoxing](https://discuss.elastic.co/u/yuemaoxing)
#### Post date: [April 25, 2016, 11:19am UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/3 "2016-04-25T11:19:19Z")

</div>

thx  
In my case, parent mapping already has child mapping.

---

<div class="post-metadata">

### Author: ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)
#### Post date: [April 25, 2016, 1:55pm UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/4 "2016-04-25T13:55:35Z")

</div>

I opened an issue for this: [https://github.com/elastic/elasticsearch/issues/17956](https://github.com/elastic/elasticsearch/issues/17956)

---

<div class="post-metadata">

### Author: ![yuemaoxing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuemaoxing/32/41118_2.png) [@yuemaoxing](https://discuss.elastic.co/u/yuemaoxing)
#### Post date: [April 26, 2016, 2:08am UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/5 "2016-04-26T02:08:15Z")

</div>

Thank you!

---

<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:56pm UTC](https://discuss.elastic.co/t/how-to-create-a-child-type-when-its-parent-type-is-already-exist-in-elasticsearch-2-x/48114/6 "2017-07-05T22:56:22Z")

</div>


