# How to add new type to an existing index using Elasticsearch 6.x high level java REST API

**URL:** https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037
**Category:** Elasticsearch
**Created:** [October 4, 2018, 11:06am UTC](https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037 "2018-10-04T11:06:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Anjana\_Surendrababu](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Anjana\_Surendrababu](https://discuss.elastic.co/u/Anjana_Surendrababu)
#### Post date: [October 4, 2018, 11:06am UTC](https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037/1 "2018-10-04T11:06:55Z")

</div>

How can I add a new type to an existing index using Elasticsearch 6.x high level java REST API?

I am using a PutMappingRequest , it adds the first type when I am trying to add the second type it says

Rejecting mapping update to [db] as the final mapping would have more than 1 type

Any help on this?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 4, 2018, 11:29am UTC](https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037/2 "2018-10-04T11:29:35Z")

</div>

[Elasticsearch 6.x only supports a single type per index](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/removal-of-types.html), so you can not do this. A workaround may be to add the type as a normal field and then filter on this.

---

<div class="post-metadata">

### Author: ![Anjana\_Surendrababu](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Anjana\_Surendrababu](https://discuss.elastic.co/u/Anjana_Surendrababu)
#### Post date: [October 4, 2018, 11:56am UTC](https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037/3 "2018-10-04T11:56:23Z")

</div>

I am trying to index around 5 modules in my application, which may or may not have same properties. And I am trying to implement a global search here, like if I search for a word I want to return the results from all the 5 modules. Which will be a better approach for me? Having a custom type property and keeping everything in a single index or having separate indices for each modules

---

<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: [November 1, 2018, 11:56am UTC](https://discuss.elastic.co/t/how-to-add-new-type-to-an-existing-index-using-elasticsearch-6-x-high-level-java-rest-api/151037/4 "2018-11-01T11:56:25Z")

</div>

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