修改
http://127.0.0.1:9200/update/book/novel?id=&time=
UpdateRequest update=new UpdateRequest("book","novel",id);
XContentFactory content = XContentFactory.jsonBuilder().startObject().field("XXX",value).endObject();//可以增加判空逻辑,最后必须以endObject()结尾。
update.doc();
UpdateResponse result = client.update(update).get();
result.getResult();
验证:
http://127.0.0.1:9200/get/book/novel?id=
java 更新
java 更新2
updateRequest update = new UpdateRequest();
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
buildet.field();
builder.endObject();
update.doc(builder);
this.client.update(update).get();