# Updates and executing scripts on fields containing @

**URL:** <https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168>\
**Category:** Elasticsearch\
**Created:** [September 27, 2012, 9:45am UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168 "2012-09-27T09:45:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jelle\_Smet](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@Jelle\_Smet](https://discuss.elastic.co/u/Jelle_Smet)\
**Post date:** [September 27, 2012, 9:45am UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/1 "2012-09-27T09:45:46Z")

</div>

Hi list,

My goal is to update an array which name starts with an @ sign.  
For this I use the \_update API by executing an mvel script. It seems to  
work fine on elements which have a regular name.

I'm running version 0.19.9

See following output:

curl -XGET '[http://xxx:9200/\_cluster/health?pretty=true](http://xxx:9200/_cluster/health?pretty=true)'  
{  
"cluster\_name" : "elasticsearch",  
"status" : "yellow",  
"timed\_out" : false,  
"number\_of\_nodes" : 2,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 85,  
"active\_shards" : 85,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 85  
}

This works:  
curl -XPUT xxx:9200/test/test/1 -d '{"counter" : 1, "tags" : ["fubar1"]}'  
curl -XPOST 'xxx:9200/test/test/1/\_update' -d '{"script" : "ctx.\_source.tags += tag","params": {"tag":"fubar2"}}'

This does not work:  
curl -XPUT xxx:9200/test/test/2 -d '{"counter" : 1, "@tags" : ["fubar1"]}'  
curl -XPOST 'xxx:9200/test/test/2/\_update' -d '{"script" : "ctx.\_source.@tags += tag","params": {"tag":"fubar2"}}'

{"error":"ElasticSearchIllegalArgumentException[failed to execute script]; nested: ArrayIndexOutOfBoundsException[0]; ","status":400}

--

---

<div class="post-metadata">

**Author:** ![Jelle\_Smet](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@Jelle\_Smet](https://discuss.elastic.co/u/Jelle_Smet)\
**Post date:** [September 27, 2012, 10:15am UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/2 "2012-09-27T10:15:04Z")

</div>

Submitted as bugreport:

> <https://github.com/elastic/elasticsearch/issues/2293>

--

---

<div class="post-metadata">

**Author:** ![clive\_walmsley](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@clive\_walmsley](https://discuss.elastic.co/u/clive_walmsley)\
**Post date:** [April 5, 2013, 5:58pm UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/3 "2013-04-05T17:58:05Z")

</div>

Hi Jelle,

I'm having the same issue. Were you able to find a solution or workaround  
for this?

Thanks,

Clive

On Thursday, September 27, 2012 5:45:46 AM UTC-4, Jelle Smet wrote:

> Hi list,
> 
> My goal is to update an array which name starts with an @ sign.  
> For this I use the \_update API by executing an mvel script. It seems to  
> work fine on elements which have a regular name.
> 
> I'm running version 0.19.9
> 
> See following output:
> 
> curl -XGET '[http://xxx:9200/\_cluster/health?pretty=true](http://xxx:9200/_cluster/health?pretty=true)'  
> {  
> "cluster\_name" : "elasticsearch",  
> "status" : "yellow",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 2,  
> "number\_of\_data\_nodes" : 1,  
> "active\_primary\_shards" : 85,  
> "active\_shards" : 85,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 85  
> }
> 
> This works:  
> curl -XPUT xxx:9200/test/test/1 -d '{"counter" : 1, "tags" : ["fubar1"]}'  
> curl -XPOST 'xxx:9200/test/test/1/\_update' -d '{"script" : "ctx.\_source.tags += tag","params": {"tag":"fubar2"}}'
> 
> This does not work:  
> curl -XPUT xxx:9200/test/test/2 -d '{"counter" : 1, "@tags" : ["fubar1"]}'  
> curl -XPOST 'xxx:9200/test/test/2/\_update' -d '{"script" : "ctx.\_source.@tags += tag","params": {"tag":"fubar2"}}'
> 
> {"error":"ElasticSearchIllegalArgumentException[failed to execute script]; nested: ArrayIndexOutOfBoundsException[0]; ","status":400}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 5, 2013, 6:18pm UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/4 "2013-04-05T18:18:30Z")

</div>

See

> <https://github.com/elastic/elasticsearch/issues/2852#issuecomment-15935223>
>
> elasticsearch-0.20.5
> 
> \---
> 
> curl localhost:9200/logstash-2013.03.28/xxxxx\_log-typ…e/qWtE27BWQuCsjBWUxoCxdg
> 
> ============================\>
> 
> {"\_index":"logstash-2013.03.28","\_type":"xxxxx\_log-type","\_id":"qWtE27BWQuCsjBWUxoCxdg","\_version":2,"exists":true, "\_source" : {"@source":"file://xxxxx.xxxx.xxxx/opt/xxxx/xxxx/logs/xxxx.log","@tags":\["multiline","grepped"\],"@fields":{"timestamp":\["2013-03-28 04:40:00.034"\],"thread":\["xxxxxxx\_xxxxxxx-9"\],"logseverity":\["ERROR"\],"class\_name":\["xxxxx.xxxxx.xxxxx.xxxxxxx.xxxxxx.xxxxxxxxx"\],"message":\["Error xxxxxx xxx xxxxx xxxxxxxx 'xxxxxx.xxxxxxx.xxxx.xxxxx.xxxxxxx.xxxxx@xxxxxxx': xxxxx xxxxxxx xxxxxxxx xxxxx."\]},"@timestamp":"2013-03-28T11:40:01.003Z","@source\_host":"xxxx.xxxxx.xxxx","@source\_path":"/opt/xxxxxxx/xxxx/xxxx/xxxxxxxx.log","@message":"2013-03-28 04:40:00.034 \[xxxxxxxxxxx\_xxxxxxxx-9\] ERROR xxxx.xxxx.xxxx.xxxx.xxx - Error xxxxx xxx xxxxx xxxxx 'xxxxxx.xxxxxxx.xxxx.xxxxx.xxxxxxx.xxxxx@xxxxxxx': xxxxxx xxxxx xxxxx xxxxxxxx xxxxx.\\nxxxx.xxxxx.xxxxxxxxx: xxxxxxx xxxxxxxxxx xxxxxxxx xxxxxx.\\n\\tat xxxxxx.xxxxxxx.xxxx.xxxxx.xxxxxxx.xxxxx.xxxxxx(xxxxxxxx.java:354) ~\[xxxxxx-xxxxxx-xxxx-1.1.1.jar:na\]\\n\\tat xxxxxx.xxxxxxx.xxxx.xxxxx.xxxxxxx.xxxxx.xxxxxxxx(xxxxxxxx.java:210) \[xxxx.xxxx.xxxx.xxxxx-1.1.1.jar:na\]\\n\\tat xxxxxx.xxxxxxx.xxxx.xxxxx.xxxxxxx.xxxxx.xxxxxxxx(xxxxxxxxxxxxxx.java:72) \[xxxx.xxxxxxxxxx.xxxxxx.xxxxxx-1.1.1.jar:na\]\\n\\tat xxxx.xxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxxxxxx.xxxxxxxxxxx(xxxxxxxxxxxxxx.java:66) \[xxx.xxxxxxx.xxxx.xxxxxx-1.1.1.jar:na\]\\n\\tat sun.xxxxxxx.xxxxxxxxx.xxxxx(Unknown Source) ~\[na:na\]\\n\\tat sun.xxxxx.xxxxxxxxxxx.xxxxx(xxxxxxxxxxxxxx.java:43) ~\[na:1.1.1\_17\]\\n\\tat xxxx.xxxx.xxxxx.xxxx.xxxxx(xxxxx.java:601) ~\[na:1.1.1\_17\]\\n\\tat xxxx.xxxxx.xxxx.xxxxx.xxxxx(xxxxxx.java:273) \[xxxx.xxxxxxxx.xxxx-1.1.1.RELEASE.jar:1.1.1.RELEASE\]\\n\\tat xxx.xxxxxxxxxx.xxxxxxxx.xxxxx.xxxxxxxxxxxxxxx$xxxxxxxxxxxxxx.xxxxxxxxx(xxxxxxxxxxxxxxxx.java:264) \[xxx.xxxxxxxxxxxxxxxx.xxxxxxxx.xxxxx-1.1.1.RELEASE.jar:1.1.1.RELEASE\]\\n\\tat xxxxxx.xxxxxxxxxxx.xxxxxxx.xxxxxxx.xxxxxxxxx.xxxxxx(xxxxxxxx.java:86) \[xxxxxx.xxxxxx.xxxxxx.xxxx-1.1.1.RELEASE.jar:1.1.1.RELEASE\]\\n\\tat xxx.xxxxxx.xxxx.xxxxxx.xxxx(xxxxxx.java:202) \[xxxxxxx-1.1.1.jar:1.1.1\]\\n\\tat xxxx.xxxxxx.xxxx.xxxxxxxxxxx$xxxxxxx.xxx(xxxxxx.java:529) \[xxxx-1.1.1.jar:1.1.1\]","@type":"xxxxx\_log-type","reported":"yes"}}
> 
> \---
> 
> No mappings defined
> 
> \---
> 
> curl -XPOST 'localhost:9200/logstash-2013.03.28/xxxxx\_log-type/qWtE27BWQuCsjBWUxoCxdg/\_update' -d '{
> "script" : "ctx.\_source.tags += tag",
> "params" : {
> "tag" : "reported"
> }
> }'
> 
> =========================\>
> 
> Execption:
> {"error":"ElasticSearchIllegalArgumentException\[failed to execute script\]; nested: PropertyAccessException\[\[Error: could not access: tags; in class: java.util.LinkedHashMap\]\\n\[Near : {... ctx.\_source.tags+tag ....}\]\\n ^\\n\[Line: 1, Column: 1\]\]; ","status":400}

On Friday, April 5, 2013 1:58:05 PM UTC-4, [clive.w...@chloeandisabel.com](mailto:clive.w...@chloeandisabel.com)  
wrote:

> Hi Jelle,
> 
> I'm having the same issue. Were you able to find a solution or workaround  
> for this?
> 
> Thanks,
> 
> Clive
> 
> On Thursday, September 27, 2012 5:45:46 AM UTC-4, Jelle Smet wrote:
> 
> > Hi list,
> > 
> > My goal is to update an array which name starts with an @ sign.  
> > For this I use the \_update API by executing an mvel script. It seems to  
> > work fine on elements which have a regular name.
> > 
> > I'm running version 0.19.9
> > 
> > See following output:
> > 
> > curl -XGET '[http://xxx:9200/\_cluster/health?pretty=true](http://xxx:9200/_cluster/health?pretty=true)'  
> > {  
> > "cluster\_name" : "elasticsearch",  
> > "status" : "yellow",  
> > "timed\_out" : false,  
> > "number\_of\_nodes" : 2,  
> > "number\_of\_data\_nodes" : 1,  
> > "active\_primary\_shards" : 85,  
> > "active\_shards" : 85,  
> > "relocating\_shards" : 0,  
> > "initializing\_shards" : 0,  
> > "unassigned\_shards" : 85  
> > }
> > 
> > This works:  
> > curl -XPUT xxx:9200/test/test/1 -d '{"counter" : 1, "tags" : ["fubar1"]}'  
> > curl -XPOST 'xxx:9200/test/test/1/\_update' -d '{"script" : "ctx.\_source.tags += tag","params": {"tag":"fubar2"}}'
> > 
> > This does not work:  
> > curl -XPUT xxx:9200/test/test/2 -d '{"counter" : 1, "@tags" : ["fubar1"]}'  
> > curl -XPOST 'xxx:9200/test/test/2/\_update' -d '{"script" : "ctx.\_source.@tags += tag","params": {"tag":"fubar2"}}'
> > 
> > {"error":"ElasticSearchIllegalArgumentException[failed to execute script]; nested: ArrayIndexOutOfBoundsException[0]; ","status":400}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Brian\_Phunk\_Gadoury](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@Brian\_Phunk\_Gadoury](https://discuss.elastic.co/u/Brian_Phunk_Gadoury)\
**Post date:** [April 5, 2013, 6:29pm UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/5 "2013-04-05T18:29:10Z")

</div>

I'm very sorry to hijack an unrelated thread, but does anyone know why  
google groups just deleted my new post on my SearchParseException? It  
certainly didn't have anything objectionable or spammy in it.

-Brian

On Friday, April 5, 2013 12:18:30 PM UTC-6, Igor Motov wrote:

> See  
> [API Update Tags Problem · Issue #2852 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2852#issuecomment-15935223)
> 
> On Friday, April 5, 2013 1:58:05 PM UTC-4, clive.w...@chloeandisabel.comwrote:
> 
> > Hi Jelle,
> > 
> > I'm having the same issue. Were you able to find a solution or  
> > workaround for this?
> > 
> > Thanks,
> > 
> > Clive
> > 
> > On Thursday, September 27, 2012 5:45:46 AM UTC-4, Jelle Smet wrote:
> > 
> > > Hi list,
> > > 
> > > My goal is to update an array which name starts with an @ sign.  
> > > For this I use the \_update API by executing an mvel script. It seems to  
> > > work fine on elements which have a regular name.
> > > 
> > > I'm running version 0.19.9
> > > 
> > > See following output:
> > > 
> > > curl -XGET '[http://xxx:9200/\_cluster/health?pretty=true](http://xxx:9200/_cluster/health?pretty=true)'  
> > > {  
> > > "cluster\_name" : "elasticsearch",  
> > > "status" : "yellow",  
> > > "timed\_out" : false,  
> > > "number\_of\_nodes" : 2,  
> > > "number\_of\_data\_nodes" : 1,  
> > > "active\_primary\_shards" : 85,  
> > > "active\_shards" : 85,  
> > > "relocating\_shards" : 0,  
> > > "initializing\_shards" : 0,  
> > > "unassigned\_shards" : 85  
> > > }
> > > 
> > > This works:  
> > > curl -XPUT xxx:9200/test/test/1 -d '{"counter" : 1, "tags" : ["fubar1"]}'  
> > > curl -XPOST 'xxx:9200/test/test/1/\_update' -d '{"script" : "ctx.\_source.tags += tag","params": {"tag":"fubar2"}}'
> > > 
> > > This does not work:  
> > > curl -XPUT xxx:9200/test/test/2 -d '{"counter" : 1, "@tags" : ["fubar1"]}'  
> > > curl -XPOST 'xxx:9200/test/test/2/\_update' -d '{"script" : "ctx.\_source.@tags += tag","params": {"tag":"fubar2"}}'
> > > 
> > > {"error":"ElasticSearchIllegalArgumentException[failed to execute script]; nested: ArrayIndexOutOfBoundsException[0]; ","status":400}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:42am UTC](https://discuss.elastic.co/t/updates-and-executing-scripts-on-fields-containing/9168/6 "2017-07-06T02:42:32Z")

</div>


