# Append nested object to exisiting nested field in elasticsearch

**URL:** https://discuss.elastic.co/t/append-nested-object-to-exisiting-nested-field-in-elasticsearch/215696
**Category:** Elasticsearch
**Created:** [January 20, 2020, 9:24am UTC](https://discuss.elastic.co/t/append-nested-object-to-exisiting-nested-field-in-elasticsearch/215696 "2020-01-20T09:24:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ram\_29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_29/32/47522_2.png) [@Ram\_29](https://discuss.elastic.co/u/Ram_29)
#### Post date: [January 20, 2020, 9:24am UTC](https://discuss.elastic.co/t/append-nested-object-to-exisiting-nested-field-in-elasticsearch/215696/1 "2020-01-20T09:24:03Z")

</div>

I'm having nested object like below

"appdata": {  
"type":"nested",  
"include\_in\_parent":true,  
"properties": {  
"accessType": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"appname": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"eventtime": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}

I'm updating it using below

POST dashboard\_write/\_update/1199CF2F77603304A275DD112D9FA747  
{

```
"script" : {

    "source": "if (ctx._source.appdata == null) { ctx._source.appdata = params.appdata } else { ctx._source.appdata=ctx._source.appdata+params.appdata}",

    "lang": "painless",

    "params" : {

        "appdata" : {
        "accessType" : "second_app",
        "appname" : "third",
        "eventtime" : "Jan 20 12:18:39"
      }

    }

}

```

It's giving runtime error

"type": "class\_cast\_exception",  
"reason": "Cannot apply [+] operation to types [java.util.LinkedHashMap] and [java.util.HashMap]."

I'm expecting appdata to be as below

"appdata" : [{  
"accessType" : "test\_app",  
"appname" : "first",  
"eventtime" : "Jan 20 12:18:39"  
},{  
"accessType" : "test\_app",  
"appname" : "second",  
"eventtime" : "Jan 20 12:18:39"  
},]

---

<div class="post-metadata">

### Author: ![Ram\_29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_29/32/47522_2.png) [@Ram\_29](https://discuss.elastic.co/u/Ram_29)
#### Post date: [January 28, 2020, 9:41am UTC](https://discuss.elastic.co/t/append-nested-object-to-exisiting-nested-field-in-elasticsearch/215696/2 "2020-01-28T09:41:34Z")

</div>

This is config issue from my side. Above code works well for logstash too.. Thanks

---

<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: [February 25, 2020, 9:41am UTC](https://discuss.elastic.co/t/append-nested-object-to-exisiting-nested-field-in-elasticsearch/215696/3 "2020-02-25T09:41:36Z")

</div>

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