@SpringBootTestpublic class MyTest{//注入RestHighLevelClient对象@Autowiredprivate RestHighLevelClient restHighLevelClient;@Testpublic void test() throws IOException {//准备GetRequest请求对象,并指定索引库名和文档idGetRequest getRequest = new GetRequest(索引库名, 文档id);//发送请求,得到响应对象GetResponse getResponse = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT);//获取响应对象中的Json数据String json = getResponse.getSourceAsString();//反序列化Json,这里需要引入fastjson的依赖类名 对象名 = JSON.parseObject(json, 类名.class);}}
