# Update a list json

**URL:** <https://discuss.elastic.co/t/update-a-list-json/79393>\
**Category:** Logstash\
**Created:** [March 21, 2017, 11:02am UTC](https://discuss.elastic.co/t/update-a-list-json/79393 "2017-03-21T11:02:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![E.Eric](https://avatars.discourse-cdn.com/v4/letter/e/dec6dc/32.png) [@E.Eric](https://discuss.elastic.co/u/E.Eric)\
**Post date:** [March 21, 2017, 11:02am UTC](https://discuss.elastic.co/t/update-a-list-json/79393/1 "2017-03-21T11:02:01Z")

</div>

Hello,

here is my field :  
`"servers": [{"name":"value1", "ip":"value1"}, {"name":"value2","ip":"value2"}]`

I want to update it with elasticsearch output plugin by adding a new server.  
this is my configuration:  
`mutate { rename => {"name" => "[server][name]" "ip"	=> "[server][ip]"	} } ruby { code => " event['server'] = [event['server']] " }`  
`output {`  
`elasticsearch {`  
`action => "update"`  
`index => "servers"`  
`document_type => "server"`  
`document_id => "%{server_id}"`  
`hosts => [""]`  
`doc_as_upsert => true`  
`script_lang => "groovy"`  
`script_type => "inline"`  
`retry_on_conflict => 3`  
`script => '`  
`ctx._source.servers.add("%{server}");`  
`'`  
`}`

`}`

The error:

"reason"=\>"failed to compile groovy script", "caused\_by"=\>{"type"=\>"multiple\_compilation\_errors\_exception", "reason"=\>"startup failed:\n156b9df68283e0636d5ae7e1331a1c5e0b80b7ec: 2: unexpected token: name @ line 2, column 39.\n \t\t\t\t\tctx.\_source.servers.add("{"name"=\>"localhost", "ip"=\>"176.16.20.4"}"); \t\t\t\t\t\n ^\n\n1 error\n"}}}}}}, :level=\>:warn}

Is there any help please.

---

<div class="post-metadata">

**Author:** ![Mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mohamed](https://discuss.elastic.co/u/Mohamed)\
**Post date:** [March 21, 2017, 1:20pm UTC](https://discuss.elastic.co/t/update-a-list-json/79393/2 "2017-03-21T13:20:32Z")

</div>

I'm facing the same probleme. @magnusbaeck any help please ?

---

<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:** [April 18, 2017, 1:20pm UTC](https://discuss.elastic.co/t/update-a-list-json/79393/3 "2017-04-18T13:20:52Z")

</div>

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