I was trying to insert mapping in the RestHighLevelClient of elasticsearch 6.2.1
From the following link I had found the following code for the insertion of mapping
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(ipaddress, port, "http")));
client.indices().putMapping(putMappingRequest);
But I was unable to find putMapping(putMappingRequest) in the client.indices()
this is the maven dependency that I had added in the project
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.2.1</version>
Can anyone help me to find out correct jar file that suits my requirement or any other way to insert mapping using RestHighLevelClient
Any help is really appreciated.
Your link points to the documentation of an unreleased version. For 6.2.1, you need to use the CreateIndexRequest
, like this:
CreateIndexRequest request = new CreateIndexRequest("twitter");
request.mapping("tweet",
" {\n" +
" \"tweet\": {\n" +
" \"properties\": {\n" +
" \"message\": {\n" +
" \"type\": \"text\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }",
XContentType.JSON);
CreateIndexResponse createIndexResponse = client.indices().create(request);