# Append values to array field

**URL:** https://discuss.elastic.co/t/append-values-to-array-field/156476
**Category:** Logstash
**Created:** [November 13, 2018, 1:09pm UTC](https://discuss.elastic.co/t/append-values-to-array-field/156476 "2018-11-13T13:09:36Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![M.alsioufi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.alsioufi/32/52269_2.png) [@M.alsioufi](https://discuss.elastic.co/u/M.alsioufi)
#### Post date: [November 14, 2018, 9:20am UTC](https://discuss.elastic.co/t/append-values-to-array-field/156476/2 "2018-11-14T09:20:51Z")

</div>

After I read this topic:

> [@Logstash Elasticsearch ouput: Append array while upserting](https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010/5):
>
> Results in the following error: "reason"=\>"compile error", "caused\_by"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"invalid sequence of tokens near ['%'].", "caused\_by"=\>{"type"=\>"no\_viable\_alt\_exception" Are you 100% sure all events have a [shodan][protocols] field? You'll have to double-quote the variable expansion, i.e. do this: script =\> 'ctx.\_source.shodan.protocols += "%{[shodan][protocols]}"' Which version of Logstash are you using? script =\> "%{[ctx][\_source][shodan][protoc…

I modified the output config to become:  
` output {  
elasticsearch {  
"hosts" =\> "[http://myEShost](http://myEShost):portnumber"  
index =\> "my\_index"  
document\_id =\> "%{a}"  
action =\> "update"  
script =\> 'if(ctx.\_source.b != null) ctx.\_source.b.add("%{b}");'

```
        }
        stdout {
            codec => json_lines
        }
    }`

```

but this is not doing the job it gives "version conflict, current version [77] is different than the one provided [76]"

---

_[View the full topic](https://discuss.elastic.co/t/append-values-to-array-field/156476)._
