Closed
Description
Java API client version
8.8.2
Java version
OpenJDK Runtime Environment (Temurin)(build 1.8.0_422-b05)
Elasticsearch Version
8.8.2
Problem description
public static void main(String[] args) throws IOException {
HttpHost httpHost = HttpHost.create("http://127.0.0.1:9200");
RestClientBuilder restClientBuilder = RestClient.builder(httpHost);
restClientBuilder.setHttpClientConfigCallback(httpAsyncClientBuilder -> {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "elas!@#"));
httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
return httpAsyncClientBuilder;
});
ElasticsearchClient client = new ElasticsearchClient(new RestClientTransport(restClientBuilder.build(),new JacksonJsonpMapper()));
CountResponse count = client.count(req->req.index("p7").q("docNo:*"));
System.out.println(count.count());
}