# POST update operation doubt

**URL:** <https://discuss.elastic.co/t/post-update-operation-doubt/186585>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 4:40am UTC](https://discuss.elastic.co/t/post-update-operation-doubt/186585 "2019-06-20T04:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vyas.radhakrishnan](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@vyas.radhakrishnan](https://discuss.elastic.co/u/vyas.radhakrishnan)\
**Post date:** [June 20, 2019, 4:40am UTC](https://discuss.elastic.co/t/post-update-operation-doubt/186585/1 "2019-06-20T04:40:54Z")

</div>

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](http://slc11zix.us.oracle.com:9200/students/documentType/s1)

{  
"Name": "student1",  
"school": "school",  
"EmailAddress": ["student1@school.com"](mailto:student1@school.com)  
}

**b) Now update the same as following**  
POST [http://slc11zix.us.oracle.com:9200/students/documentType/s1/\_update](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](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"](mailto: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 ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 20, 2019, 4:42am UTC](https://discuss.elastic.co/t/post-update-operation-doubt/186585/2 "2019-06-20T04:42:48Z")

</div>

This is expected behaviour.

> **[Update API | Elasticsearch Guide \[7.1\] | Elastic](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](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/docs-index_.html) should be used instead.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 18, 2019, 4:43am UTC](https://discuss.elastic.co/t/post-update-operation-doubt/186585/3 "2019-07-18T04:43:02Z")

</div>

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