# Nested Object insert/update

**URL:** https://discuss.elastic.co/t/nested-object-insert-update/22274
**Category:** Elasticsearch
**Created:** [February 19, 2015, 8:44pm UTC](https://discuss.elastic.co/t/nested-object-insert-update/22274 "2015-02-19T20:44:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Get2sada](https://avatars.discourse-cdn.com/v4/letter/g/ad7895/32.png) [@Get2sada](https://discuss.elastic.co/u/Get2sada)
#### Post date: [February 19, 2015, 8:44pm UTC](https://discuss.elastic.co/t/nested-object-insert-update/22274/1 "2015-02-19T20:44:31Z")

</div>

Hi Everyone:

Below nested update does not insert a new nested object in the array, Notice the added brackets []

curl -XPOST '[http://localhost:9200/v2/Test/cd196e01/\_update](http://localhost:9200/v2/Test/cd196e01/_update)' -d'{"script":"ctx.\_source.Code += Code",  
"params":{"Code":[{  
"Family":"Family",  
"Code":"Raw",  
"Code":12345,  
"Role":"",  
"Rank":4,  
"Description":"Some updates",  
"SourceType":"human",  
"SourceSequence":1,  
"SourceValue":"some value",  
"Status":"active"  
}]  
}  
}'

Getting error msg:

{"error":"ElasticsearchIllegalArgumentException[failed to execute script]; nested: GroovyScriptExecutionException[ClassCastException[java.util.HashMap cannot be cast to java.util.Map$Entry]

However, removing the brackets [] will update the existing nested object. Need to insert nested object instead.

Any help is much appreciated !!

Thank You

---

<div class="post-metadata">

### Author: ![Nelson\_Matias](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@Nelson\_Matias](https://discuss.elastic.co/u/Nelson_Matias)
#### Post date: [July 5, 2017, 10:27am UTC](https://discuss.elastic.co/t/nested-object-insert-update/22274/2 "2017-07-05T10:27:05Z")

</div>

Hi, did u manage to fix that?

---

<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: [November 4, 2022, 4:01am UTC](https://discuss.elastic.co/t/nested-object-insert-update/22274/3 "2022-11-04T04:01:26Z")

</div>


