POST update operation doubt

This doubt is regarding how POST update operation has to work,

a) Create a document as following
POST http://slc11zix.us.oracle.com:9200/students/documentType/s1

{
"Name": "student1",
"school": "school",
"EmailAddress": "student1@school.com"
}

b) Now update the same as following
POST http://slc11zix.us.oracle.com:9200/students/documentType/s1/_update
{
"doc":{
"Name": "student2",
"school": "school",
"city":"hyderabad"
}
}
**c) Following is the state of document , **shouldn't the EmailAddress be removed since the second update did not have it ?

GET http://slc11zix.us.oracle.com:9200/students/documentType/s1

{
"_index": "students",
"_type": "documentType",
"_id": "s1",
"_version": 2,
"found": true,
"_source": {
"Name": "student2",
"school": "school",
"EmailAddress": "student1@school.com",
"city": "hyderabad"
}
}

What i am expecting is "EmailAddress" is removed since second update did not have it.
Is there a issue in the Operation type used ?

This is expected behaviour.

https://www.elastic.co/guide/en/elasticsearch/reference/7.1/docs-update.html#_updates_with_a_partial_document

The update API also supports passing a partial document, which will be merged into the existing document (simple recursive merge, inner merging of objects, replacing core "keys/values" and arrays). To fully replace the existing document, the index API should be used instead.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.