Kunal Gupta
Kunal Gupta

Reputation: 1

How to write an elastic search count api in spring boot..?

Steps to write elastic search count api using spring boot.?

Upvotes: 0

Views: 841

Answers (1)

rabbitbr
rabbitbr

Reputation: 3271

Using new Java API Client:

var countRequestResponse = client.count(CountRequest.of(c -> c.index("idx_name")));
System.out.println(countRequestResponse.count());

Using Java High Client Library

var countRequest = new CountRequest();
countRequest.indices("idx_name");
var response = getClient().count(countRequest, RequestOptions.DEFAULT);
System.out.println(response.getCount());

Upvotes: 2

Related Questions