Unable to Create Index using RestHighLevelClient API, ES 7.12.1

Hi,
I am using `ES 7.12.1` and when I am trying to create the Index with the code getting an error:

client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http")));
        CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-Index");
        createIndexRequest.source("{\n" +
                "    \"settings\" : {\n" +
                "        \"number_of_shards\" : 1,\n" +
                "        \"number_of_replicas\" : 0\n" +
                "    },\n" +
                "    \"mappings\" : {\n" +
                "        \"properties\" : {\n" +
                "            \"message\" : { \"type\" : \"text\" }\n" +
                "        }\n" +
                "    },\n" +
                "    \"aliases\" : {\n" +
                "        \"twitter_alias\" : {}\n" +
                "    }\n" +
                "}", XContentType.JSON);

 CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);

Below is the error:

Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [http://localhost:9200], URI [/my-Index?master_timeout=30s&timeout=30s], status line [HTTP/1.1 404 Not Found]
{"statusCode":404,"error":"Not Found","message":"Not Found"}

And when I checked from Kibana UI, the Index has not been created.

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