目录
一、基于 JavaRestClient 查询文档
1.1、查询 API 演示
1.1.1、查询基本框架
接下里通过一个 match_all 查询所有,来演示以下基本的 API.
@Test
public void testMatchAll() throws IOException {
//1.准备 SearchRequest
SearchRequest request = new SearchRequest("hotel");
//2.准备参数
request.source().query(QueryBuilders.matchAllQuery());
//3.发送请求,并接收响应
SearchResponse response = client.search(request, RequestOptions.DEFAULT);
//4.解析响应
handlerResponse(response);
}
/**
* 处理响应
* @param response
*/
private void handlerResponse(SearchResponse response) {