# Append to a property if exists

**URL:** https://discuss.elastic.co/t/append-to-a-property-if-exists/214889
**Category:** Logstash
**Created:** [January 13, 2020, 6:29pm UTC](https://discuss.elastic.co/t/append-to-a-property-if-exists/214889 "2020-01-13T18:29:40Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Sbezgoan](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@Sbezgoan](https://discuss.elastic.co/u/Sbezgoan)
#### Post date: [January 13, 2020, 6:37pm UTC](https://discuss.elastic.co/t/append-to-a-property-if-exists/214889/2 "2020-01-13T18:37:56Z")

</div>

I have followed the discussion at

> [@Logstash Elasticsearch ouput: Append array while upserting](https://discuss.elastic.co/t/logstash-elasticsearch-ouput-append-array-while-upserting/70010/4):
>
> @magnusbaeck Thanks for your reply, I tried your suggestion: script =\> "ctx.\_source.shodan.protocols += %{[shodan][protocols]}" 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" Same error with this: script =\> "%{[ctx][\_source][shodan][protocols]} += %{[shodan][protocols]}" It indicated some syntax error near the % symbol, I'm not…

---

_[View the full topic](https://discuss.elastic.co/t/append-to-a-property-if-exists/214889)._
