How to update Nested object in elasticsearch

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.

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. Have you tried this already and something does not work as expected?

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

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.

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