elasticsearch更新操作java

/**
 * 更新操作,更新某个_id下的field的值
 * @throws IOException
 */
public static void UpdateDoc() throws IOException {   
     UpdateRequest updateRequest = new UpdateRequest("mytest11","infor2","AVysXG3Et--XJjU4w71O")//分别为index,type,_id
                .doc(jsonBuilder()
                        .startObject()
                        .field("email","999")   //更新field为email
                        .endObject());
        
            try {
                transportClient.update(updateRequest).get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if(updateRequest==null)
            System.out.println(updateRequest);
   
}

原文地址:https://www.cnblogs.com/zengxiaoyi36/p/7684654.html