修改部分
@SpringBootTestpublic class MyTest{    //注入RestHighLevelClient对象    @Autowired    private RestHighLevelClient restHighLevelClient;    @Test    public void test() throws IOException {        //准备UpdateRequest请求对象        UpdateRequest updateRequest = new UpdateRequest(索引库名, 文档id);        //构建Map集合,放入需要修改的字段数据        Map<String, Object> map = new HashMap<>();        map.put(键, 值);        //在UpdateRequest请求对象中放入Map集合        updateRequest.doc(map);        //发送请求        restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);    }}
修改全部
@SpringBootTestpublic class MyTest{    //注入RestHighLevelClient对象    @Autowired    private RestHighLevelClient restHighLevelClient;    @Test    public void test() throws IOException {        //根据id查询数据库中的数据        类名 对象名 = XxxService.getById(id值);        //转换为文档类型        文档类名 文档对象名 = new 文档类名(对象名);        //序列化Json,这里需要引入fastjson的依赖        String json = JSON.toJSONString(文档对象名);        //准备IndexRequest请求对象,并指定索引库名和文档id        IndexRequest indexRequest = new IndexRequest(索引库名).id(文档id);        //在IndexRequest请求对象中放入Json,并指定参数类型为Json        indexRequest.source(json, XContentType.JSON);        //发送请求        restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);    }}