[DOC] Modify the update example to change a document (#49228) (#49443)

Example at the moment is not changing the existing document. Update request should at least modify the existing document.
This commit is contained in:
Przemyslaw Gomulka 2019-11-22 09:54:34 +01:00 committed by GitHub
parent 1fbb248cb7
commit d42eac9cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ IndexRequest indexRequest = new IndexRequest("index", "type", "1")
UpdateRequest updateRequest = new UpdateRequest("index", "type", "1") UpdateRequest updateRequest = new UpdateRequest("index", "type", "1")
.doc(jsonBuilder() .doc(jsonBuilder()
.startObject() .startObject()
.field("gender", "male") .field("name", "Joe Dalton")
.endObject()) .endObject())
.upsert(indexRequest); <1> .upsert(indexRequest); <1>
client.update(updateRequest).get(); client.update(updateRequest).get();
@ -99,12 +99,12 @@ If the document `index/_doc/1` already exists, we will have after this operation
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
{ {
"name" : "Joe Dalton", "name" : "Joe Dalton", <1>
"gender": "male" <1> "gender": "male"
} }
-------------------------------------------------- --------------------------------------------------
// NOTCONSOLE // NOTCONSOLE
<1> This field is added by the update request <1> This field is updated by the update request
If it does not exist, we will have a new document: If it does not exist, we will have a new document: