Java api put index settings and mappings ResourceAlreadyExistsException

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

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

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

Apparently no.

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

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