I am trying to move from Elastic High level rest client to Elastic Java API Client (Low Level Rest Client). I am able to get the response, but i want to set the timeout for my elastic query.
But this timeout method is accepting a string value, which i am not able to pass the value here.
String searchText = "bike";
SearchResponse<Product> response = esClient.search(s -> s
.index("products")
.timeout()
.query(q -> q
.match(t -> t
.field("name")
.query(searchText)
)
),
Product.class
);
This is the documentation for the method https://artifacts.elastic.co/javadoc/co/elastic/clients/elasticsearch-java/8.0.1/co/elastic/clients/elasticsearch/core/SearchRequest.Builder.html#timeout(java.lang.String)
Can someone help, how can I pass timeout value as String ??
I was able to solve this by passing a simple time value,
String searchText = "bike";
SearchResponse<Product> response = esClient.search(s -> s
.index("products")
.timeout("450ms")
.query(q -> q
.match(t -> t
.field("name")
.query(searchText)
)
),
Product.class
);