# How to update Nested object in elasticsearch

**URL:** https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611
**Category:** Elasticsearch
**Created:** [May 13, 2018, 9:41am UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611 "2018-05-13T09:41:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kartheek91](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kartheek91](https://discuss.elastic.co/u/kartheek91)
#### Post date: [May 13, 2018, 9:41am UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611/1 "2018-05-13T09:41:16Z")

</div>

Hi all developing an application and i need to update nested object. I'm not able to update the nested document.Can anyone help me please/  
{  
"\_index": "i9",  
"\_type": "i9details",  
"\_id": "OjmfWGMBhKzS2hoOoiJC",  
"\_score": 1,  
"\_source": {  
"employee": {  
"id": 37,  
"accountId": 3,  
"firstName": "kiran",  
"lastName": "a",  
"middleName": "N/A",  
"maidenName": "N/A",  
"addressId": 36,  
"sSNEnc": "0LhuT3568cCAoM74Ip/doPHgP0XPaIKGAN9eaVXAyyNxAC3vPJBKbXo0d17mNiJnZxqT4v748h69A3P3WJsACAYOKGCIF9xgN5ncKq037pYm/YP5FJet8KJ/A6RDz29Y4HGCxPA9az43EmyTGhCRksBL41MWWdsxSgPSR4XfRzjqBn17bj1zPG1CsSwXq8zZswjlz/m+TTkfop9lQFz9yhYaMmcaZvi5zWiOEz7b/5v/N5FkDiCqrx6CKi84nXZp9eH+Q6JTX77tuWUL5peciZrPwo4v18pA1xV7ymicUqy+q0V96NiNuOfRz5seTBAcSc9bqDYTbRVhcRMgbg/KMg==",  
"sSNHash": "sbI+JOA4SmGm9a7/nmE5dbIlZP+H3JDQL07wZywpzD8=",  
"sSNLast4": "0000",  
"email": "N/A",  
"phone": "N/A",  
"createdOn": "2018-01-30T11:26:51.403",  
"modifiedOn": "2018-01-30T11:27:08.067",  
"eGuid": "71e7a2cc-ab24-4d52-9663-977561d36e16"  
},  
"i9s": [  
{  
"id": 41,  
"employeeId": 37,  
"firstName": "kiran",  
"lastName": "a",  
"middleName": "N/A",  
"maidenName": "N/A",  
"addressId": 36,  
"isSSNAppliedFor": true,  
"sSNEnc": "HKsYuisa/NkFW0K51AabeG7DU1X7zv0/LurKsMGBUzBL+FaVexrixmeDQ+jqxVM0DMqsh3XWuPAAbeq2JYx8+qqpZ6YwU9gTUj/YMHleYFvaLKWro7DVQrouFKTllaAqJNcuKfPtIMD6LtHVpu9xwPMe7W6wfonwr0KQa0nvxb7nR+x/b2bbpgWF/Jb6yCs/vX0uQk+08SD13BNG9dLVnoEDTA5I8RNXFSjN3z0HFGmXdGzvoffkJd/GSd0jNWej7AGAxfIzbSnpXMs3l97DK5ayRkCpTxhhQ7xDOxAOZqc1q2FBm7YAbAwm+J1qVrw2Ks0AItglZm5XE5+Ox9eIsg==",  
"sSNHash": "sbI+JOA4SmGm9a7/nmE5dbIlZP+H3JDQL07wZywpzD8=",  
"sSNLast4": "0000",  
"dOB": "2000-05-04T00:00:00",  
"formTemplateId": 1,  
"email": "N/A",  
"phone": "N/A",  
"citizenshipTypeId": 4,  
"locationId": 7,  
"allienWorkAuthzId": 37,  
"hireDate": "2019-01-09T00:00:00",  
"employeeSignatureIP": "172.31.16.254",  
"employerRepId": 0,  
"createdOn": "2018-01-30T11:26:51.463",  
"modifiedOn": "2018-01-30T11:27:08.067",  
"guid": "5ab98fdf-fb3a-4ece-b4d8-e97815fca88b",  
"isInActive": 0  
}  
],  
"i9Status": 501  
}  
}

In the above document we have i9s array right we need to add a field in that json document.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [May 14, 2018, 2:40pm UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611/2 "2018-05-14T14:40:31Z")

</div>

can you please explain what the concrete problem here is? You can update a document by either putting it again or by using the [update API](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-update.html). Have you tried this already and something does not work as expected?

---

<div class="post-metadata">

### Author: ![kartheek91](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kartheek91](https://discuss.elastic.co/u/kartheek91)
#### Post date: [May 16, 2018, 10:03am UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611/3 "2018-05-16T10:03:18Z")

</div>

yes do we need to pass the whole document.We have concept called partial update of document in elasticsearch

---

<div class="post-metadata">

### Author: ![RahulD](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RahulD](https://discuss.elastic.co/u/RahulD)
#### Post date: [May 16, 2018, 8:10pm UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611/4 "2018-05-16T20:10:11Z")

</div>

It is better if you update the whole document. We had a similar problem and realized that updating the whole document by passes other issues that pop up because of partial updates failing or being missed. As far as I know, ES does a complete reindex for nested documents even when you update one field for the document.

---

<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: [June 13, 2018, 8:10pm UTC](https://discuss.elastic.co/t/how-to-update-nested-object-in-elasticsearch/131611/5 "2018-06-13T20:10:13Z")

</div>

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