狐的传说
我认为你不能在RestHighLevelClient 中添加查询参数,因为它的主要目标是公开 API 特定的方法,这些方法接受请求对象作为参数并返回响应对象。由于RestHighLevelClient建立在 Low Level REST Client 之上,您可以使用它来添加查询参数。RestHighLevelClient client = new RestHighLevelClient( RestClient.builder( new HttpHost("localhost", 9200, "http"), new HttpHost("localhost", 9201, "http")));使用它从 RestHighLevelClient 获取低级客户端:RestClient lowLevelClient = client.getLowLevelClient();低级 REST 客户端有一个方法 performRequest 接受查询参数:lowLevelClient.performRequest(method, endpoint, params, entity, null);方法说明:public Response performRequest(String method, String endpoint, Map<String, String> params, HttpEntity entity, HttpAsyncResponseConsumerFactory httpAsyncResponseConsumerFactory, Header... headers) throws IOException { SyncResponseListener listener = new SyncResponseListener(maxRetryTimeoutMillis); performRequestAsync(method, endpoint, params, entity, httpAsyncResponseConsumerFactory, listener, headers); return listener.get(); }