# Update Nested object with logstash

**URL:** https://discuss.elastic.co/t/update-nested-object-with-logstash/72672
**Category:** Logstash
**Created:** [January 24, 2017, 4:41pm UTC](https://discuss.elastic.co/t/update-nested-object-with-logstash/72672 "2017-01-24T16:41:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Oullion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_oullion/32/46106_2.png) [@Michael\_Oullion](https://discuss.elastic.co/u/Michael_Oullion)
#### Post date: [January 24, 2017, 4:41pm UTC](https://discuss.elastic.co/t/update-nested-object-with-logstash/72672/1 "2017-01-24T16:41:10Z")

</div>

Hello,

I spend the whole day reading and trying to update partial object with nested object.

First, I define a mapping :

```
"Info": {
          "type": "nested", 
          "properties": {
            "InfoName": {
				"type": "text", 
				"fields": {
					"raw": { 
						"type": "keyword"
					}
				}
        	},
            "Value": {
				"type": "text", 
				"fields": {
					"raw": { 
						"type": "keyword"
					}
				}
        	}
          }
        }

```

then I post 2 messages with Update API :  
[http://xxxxxxx:9200/xboud/document/1/\_update](http://xxxxxxx:9200/xboud/document/1/_update)

```
{
 	"scripted_upsert":true,
    "script" : {
        "inline": "if(ctx._source.Info == null){ctx._source.Info = []} ctx._source.Info.add(params.tag) ",
        "lang": "painless",
        "params" : {
            "tag" : {"InfoName":"green", "Value":"valeur"}
        }
    },
    "upsert" : {}
}

```

I get what I want :

```
{
    "_index": "xboud",
    "_type": "document",
    "_id": "1",
    "_version": 6,
    "found": true,
    "_source": {
        "Info": [
            {
                "Value": "valeur",
                "InfoName": "green"
            },
            {
                "Value": "valeur2",
                "InfoName": "green2"
            }
        ]
    }
}

```

Now,  
I can't find a way to do this with logstash....  
My last try was :

```
elasticsearch
			{	
				hosts => ["xxxx.corp.lan:9200"] 
				index => "xbound"
				action => "update"
				document_id => "%{docid}"
				document_type => "document"
				script => 'if(ctx._source.Info == null){ctx._source.Info = []} ctx._source.Info.add("%{temp}")'
				doc_as_upsert => true
			}

```

but I get the exception :  
_java.lang.IllegalArgumentException: Missing Ruby class handling for full class name=java.util.HashMap_

Logstash version : 5.1.2  
Java : jre 1.8.0\_102  
OS : windows

Any ideas?

---

<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 21, 2017, 4:41pm UTC](https://discuss.elastic.co/t/update-nested-object-with-logstash/72672/2 "2017-02-21T16:41:30Z")

</div>

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