# Java api put index settings and mappings ResourceAlreadyExistsException

**URL:** <https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705>\
**Category:** Elasticsearch\
**Created:** [July 4, 2017, 2:35am UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705 "2017-07-04T02:35:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Dimitriou](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Dimitriou](https://discuss.elastic.co/u/Chris_Dimitriou)\
**Post date:** [July 4, 2017, 2:35am UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705/1 "2017-07-04T02:35:44Z")

</div>

I try to make an index using the JAVA API like this

```
        cl.admin().indices().prepareCreate("index")
            .setSettings(settingsBuilder)
            .addMapping("event", mappingBuilder)
            .get();

```

but i get this exception Caused by: [index/fQUXl2xIT6CQcAuE4EMQGw] ResourceAlreadyExistsException[index [index/fQUXl2xIT6CQcAuE4EMQGw] already exists]

when i go after to kibana i see my index is there, and when i comment out the above lines there is no index in kibana

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 4, 2017, 5:03am UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705/2 "2017-07-04T05:03:23Z")

</div>

If the index already exists, you can't create it again.

---

<div class="post-metadata">

**Author:** ![Chris\_Dimitriou](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Chris\_Dimitriou](https://discuss.elastic.co/u/Chris_Dimitriou)\
**Post date:** [July 4, 2017, 1:53pm UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705/3 "2017-07-04T13:53:26Z")

</div>

But this is the first and only time i try to create it

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 4, 2017, 2:15pm UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705/4 "2017-07-04T14:15:32Z")

</div>

Apparently no.

May be something wrong in your code? Like you are calling two times the same code?

---

<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 1, 2017, 2:15pm UTC](https://discuss.elastic.co/t/java-api-put-index-settings-and-mappings-resourcealreadyexistsexception/91705/5 "2017-08-01T14:15:53Z")

</div>

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