Hi,
How do I check if index exist in JAVA API 8.2.
In v.7.x I used:
GetIndexRequest request = new GetIndexRequest("yourindexname");
restHighLevelclient.indices().exists(request, RequestOptions.DEFAULT);
Hi,
How do I check if index exist in JAVA API 8.2.
In v.7.x I used:
GetIndexRequest request = new GetIndexRequest("yourindexname");
restHighLevelclient.indices().exists(request, RequestOptions.DEFAULT);
Hi!!
Try:
var result = client.indices().exists(ExistsRequest.of(e -> e.index("name_index")));
RestHighLevelClient is deprecated in 8.2 so I cant use client.indices().exists.
RestHighLevelClient is changed to RestClient.
My code is Java API Client
version 8.2?
Yes.
what is the client object in:
var result = client.indices().exists(ExistsRequest.of(e -> e.index("name_index")));
I just find out that the new way is:
Response response = client.performRequest(new Request("HEAD", "/" + index));
return response.getStatusLine().getStatusCode() == 200;```
You are using low-level client.
My code:
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchClient client = new ElasticsearchClient(transport);
BooleanResponse result = client.indices().exists(ExistsRequest.of(e -> e.index("xpto")));
System.out.println("Exists indices: " + result.value());
how to pass security parameter in this case ...username and password of Elasticsearch
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.