I am trying to create index with High Rest Client, version 6.5.0
CreateIndexRequest createIndexRequest = new CreateIndexRequest();
createIndexRequest.index(indexName);
createIndexRequest.settings(source, XContentType.JSON);
createIndexRequest.mapping(indexType, source, XContentType.JSON);
createIndexRequest.source(source, XContentType.JSON);
try {
client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
}
I am getting error as -> java.lang.IllegalStateException: mappings for type "books" were already defined
Actually there is no index in ES, its not even reaching to insert part, actually the error is thrown from createIndexRequest.source(source, XContentType.JSON);
When createIndexRequest.mapping(indexType, source, XContentType.JSON); is executed, the source is put in to map with key as indexType
When createIndexRequest.source(source, XContentType.JSON); is executed, in the api internal call, it is trying to put the source in to map with same key.
Please find below trace:
java.lang.IllegalStateException: mappings for type "taggings" were already defined
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.mapping(CreateIndexRequest.java:264)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.source(CreateIndexRequest.java:394)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.source(CreateIndexRequest.java:375)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.source(CreateIndexRequest.java:346)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.