Example at the moment is not changing the existing document. Update request should at least modify the existing document.
This commit is contained in:
parent
1fbb248cb7
commit
d42eac9cf3
|
@ -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:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue