# Logstash Elasticsearch ouput: Append array while upserting

**URL:** https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010
**Category:** Logstash
**Created:** [December 26, 2016, 2:26pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010 "2016-12-26T14:26:00Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 2, 2017, 11:04am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010/5 "2017-01-02T11:04:58Z")

</div>

> 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][protocols]} += %{[shodan][protocols]}"
> 
> ```

That's just wrong.

---

_[View the full topic](https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010)._
