[英]Set timeout in Elastic Java API Client
I am trying to move from Elastic High level rest client to Elastic Java API Client (Low Level Rest Client). 我能夠得到響應,但我想為我的彈性查詢設置超時。
但是這個超時方法正在接受一個字符串值,我無法在此處傳遞該值。
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
);
這是方法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)
有人可以幫忙,我怎樣才能將超時值作為字符串傳遞?
我能夠通過傳遞一個簡單的時間值來解決這個問題,
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
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.