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