# How to add an index with parent-child mappings without specifying type using Java API

**URL:** https://discuss.elastic.co/t/how-to-add-an-index-with-parent-child-mappings-without-specifying-type-using-java-api/71271
**Category:** Elasticsearch
**Created:** [January 11, 2017, 6:47pm UTC](https://discuss.elastic.co/t/how-to-add-an-index-with-parent-child-mappings-without-specifying-type-using-java-api/71271 "2017-01-11T18:47:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ravinaik1312](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ravinaik1312/32/62486_2.png) [@ravinaik1312](https://discuss.elastic.co/u/ravinaik1312)
#### Post date: [January 11, 2017, 6:47pm UTC](https://discuss.elastic.co/t/how-to-add-an-index-with-parent-child-mappings-without-specifying-type-using-java-api/71271/1 "2017-01-11T18:47:42Z")

</div>

I have a parent-child type that needs to be configured for an index. So, I cannot add one type first before the other as it would violate the principle that "Parent Child relationship needs to be established at index time. "

So, I have created an index and want to add two types that have a parent-child relationship. Something like this from the [parent-child-docs](https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child-mapping.html)

I plan to do the same thing but using the Java API, but it doesn't seem like there is an api that adds types only based on the mapping. All the apis seem to explicitly require the mappingType name to be specified.

ElasticSearch Version: 2.3.0

---

<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: [February 8, 2017, 6:48pm UTC](https://discuss.elastic.co/t/how-to-add-an-index-with-parent-child-mappings-without-specifying-type-using-java-api/71271/2 "2017-02-08T18:48:37Z")

</div>

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