# How to conditionally update a nested object?

**URL:** https://discuss.elastic.co/t/how-to-conditionally-update-a-nested-object/102217
**Category:** Elasticsearch
**Created:** [September 29, 2017, 7:04am UTC](https://discuss.elastic.co/t/how-to-conditionally-update-a-nested-object/102217 "2017-09-29T07:04:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![prapan](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@prapan](https://discuss.elastic.co/u/prapan)
#### Post date: [September 29, 2017, 7:04am UTC](https://discuss.elastic.co/t/how-to-conditionally-update-a-nested-object/102217/1 "2017-09-29T07:04:11Z")

</div>

I am trying to conditionally update nested object, but some how not able to do it.

My index mapping looks like

PUT in\_index  
{  
"mappings": {  
"tyepe\_index": {  
"properties": {  
"name":{  
"type": "text"  
},  
"id":{  
"type": "text"  
},  
"statuses": {  
"type": "nested",  
"properties": {  
"status":{  
"type":"text"  
},  
"time":{  
"type":"date",  
"format":"epoch\_millis"  
}  
}  
}  
}  
}  
}  
}

and my nested data looks like

"statuses": [  
{  
"status": "abc",  
"time": "15066024220000"  
},  
{  
"status": "bef",  
"time": "1506602422000"  
},  
{  
"time": "1506602422023",  
"status": "ghi"  
},  
]

I want to append status:xyz to existing nested values if the time of status:abc is less the staus:xyz time.

---

<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: [October 27, 2017, 7:06am UTC](https://discuss.elastic.co/t/how-to-conditionally-update-a-nested-object/102217/2 "2017-10-27T07:06:48Z")

</div>

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