Hi,
I am using java high level rest client v6.2.2 to connect es cluster v5.3.1. The create index api creates the index successfully but throws the exception:
Exception in thread "main" java.io.IOException: Unable to parse response body for Response{requestLine=PUT /<my index name>?master_timeout=30s&timeout=30s HTTP/1.1, host=cluster host, response=HTTP/1.1 200 OK}
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:507)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:474)
at org.elasticsearch.client.IndicesClient.create(IndicesClient.java:77)
at com.sensano.App.createIndex(App.java:66)
at com.sensano.App.main(App.java:52)
Caused by: java.lang.IllegalArgumentException: Required [index]
at org.elasticsearch.common.xcontent.ConstructingObjectParser$Target.finish(ConstructingObjectParser.java:449)
at org.elasticsearch.common.xcontent.ConstructingObjectParser$Target.access$000(ConstructingObjectParser.java:350)
at org.elasticsearch.common.xcontent.ConstructingObjectParser.parse(ConstructingObjectParser.java:170)
at org.elasticsearch.common.xcontent.ConstructingObjectParser.apply(ConstructingObjectParser.java:162)
at org.elasticsearch.action.admin.indices.create.CreateIndexResponse.fromXContent(CreateIndexResponse.java:128)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:618)
at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$2(RestHighLevelClient.java:474)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:505)
... 4 more
I have the following code:
CreateIndexRequest request = new CreateIndexRequest(index);
request.source(SCHEMA_JSON, XContentType.JSON);
CreateIndexResponse createIndexResponse = esRestHighLevelClient.indices().create(request);
SCHEMA_JSON : contains mapping, index settings etc.
Am I doing something wrong?
Thanks in advance for your help.
Best,
Ashutosh