# Question about scripting

**URL:** <https://discuss.elastic.co/t/question-about-scripting/7378>\
**Category:** Elasticsearch\
**Created:** [April 18, 2012, 1:20pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378 "2012-04-18T13:20:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 18, 2012, 1:20pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/1 "2012-04-18T13:20:20Z")

</div>

Hi,  
I want for a test indexing data with 2 fields and after that, i want  
add fields with "update".

I've try :

for($i=1; $i \< 4; $i++){  
if($i == 1){  
$result = $es-\>index(  
index =\> "toto",  
type =\> "tata",  
id =\> 1,  
data =\> {  
name =\> "big",  
surname =\> "muzzy"  
},  
);  
}  
else{  
print "tag : "; #name of the new tag  
chomp($tag = );

```
						$result = $es->update(
							index => "toto",
							type => "tata",
							id => 1,

							script => "_fields[$tag].value+=[tag]", #Doesn't work, don't

```

know how it's works  
params =\> {$tag =\> 'ok'}  
);  
}  
}

My main problem comes from the script, if you see other errors you can  
tell me too.  
So :

I'll send an SOS to the world  
I hope that someone gets my  
Message in a forum

Thanks !

---

<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 19, 2012, 4:56pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/2 "2012-04-19T16:56:15Z")

</div>

I think in the update operation you should use ctx.\_source instead of  
\_fields.

On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:

> Hi,  
> I want for a test indexing data with 2 fields and after that, i want  
> add fields with "update".
> 
> I've try :
> 
> for($i=1; $i \< 4; $i++){  
> if($i == 1){  
> $result =  
> $es-\>index(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,  
> data =\> {  
> name  
> =\> "big",  
> surname  
> =\> "muzzy"  
> },  
> );  
> }  
> else{  
> print "tag : ";  
> #name of the new tag  
> chomp($tag =  
> );
> 
> ```
> $result = 
> 
> ```
> 
> $es-\>update(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,
> 
> ```
> script => 
> 
> ```
> 
> "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> know how it's works  
> params =\>  
> {$tag =\> 'ok'}  
> );  
> }  
> }
> 
> My main problem comes from the script, if you see other errors you can  
> tell me too.  
> So :
> 
> I'll send an SOS to the world  
> I hope that someone gets my  
> Message in a forum
> 
> Thanks !

On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:

> Hi,  
> I want for a test indexing data with 2 fields and after that, i want  
> add fields with "update".
> 
> I've try :
> 
> for($i=1; $i \< 4; $i++){  
> if($i == 1){  
> $result =  
> $es-\>index(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,  
> data =\> {  
> name  
> =\> "big",  
> surname  
> =\> "muzzy"  
> },  
> );  
> }  
> else{  
> print "tag : ";  
> #name of the new tag  
> chomp($tag =  
> );
> 
> ```
> $result = 
> 
> ```
> 
> $es-\>update(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,
> 
> ```
> script => 
> 
> ```
> 
> "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> know how it's works  
> params =\>  
> {$tag =\> 'ok'}  
> );  
> }  
> }
> 
> My main problem comes from the script, if you see other errors you can  
> tell me too.  
> So :
> 
> I'll send an SOS to the world  
> I hope that someone gets my  
> Message in a forum
> 
> Thanks !

---

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 20, 2012, 8:53am UTC](https://discuss.elastic.co/t/question-about-scripting/7378/3 "2012-04-20T08:53:54Z")

</div>

Oh, i'm trying but i d'ont understand what is ctx.\_source, mainly  
"ctx".

On 19 avr, 18:56, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:

> I think in the update operation you should use ctx.\_source instead of  
> \_fields.
> 
> On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:
> 
> > Hi,  
> > I want for a test indexing data with 2 fields and after that, i want  
> > add fields with "update".
> 
> > I've try :
> 
> > for($i=1; $i \< 4; $i++){  
> > if($i == 1){  
> > $result =  
> > $es-\>index(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,  
> > data =\> {  
> > name  
> > =\> "big",  
> > surname  
> > =\> "muzzy"  
> > },  
> > );  
> > }  
> > else{  
> > print "tag : ";  
> > #name of the new tag  
> > chomp($tag =  
> > );
> 
> > ```
> > $result =
> > 
> > ```
> > 
> > $es-\>update(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,
> 
> > ```
> > script =>
> > 
> > ```
> > 
> > "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> > know how it's works  
> > params =\>  
> > {$tag =\> 'ok'}  
> > );  
> > }  
> > }
> 
> > My main problem comes from the script, if you see other errors you can  
> > tell me too.  
> > So :
> 
> > I'll send an SOS to the world  
> > I hope that someone gets my  
> > Message in a forum
> 
> > Thanks !
> 
> On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:
> 
> > Hi,  
> > I want for a test indexing data with 2 fields and after that, i want  
> > add fields with "update".
> 
> > I've try :
> 
> > for($i=1; $i \< 4; $i++){  
> > if($i == 1){  
> > $result =  
> > $es-\>index(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,  
> > data =\> {  
> > name  
> > =\> "big",  
> > surname  
> > =\> "muzzy"  
> > },  
> > );  
> > }  
> > else{  
> > print "tag : ";  
> > #name of the new tag  
> > chomp($tag =  
> > );
> 
> > ```
> > $result =
> > 
> > ```
> > 
> > $es-\>update(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,
> 
> > ```
> > script =>
> > 
> > ```
> > 
> > "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> > know how it's works  
> > params =\>  
> > {$tag =\> 'ok'}  
> > );  
> > }  
> > }
> 
> > My main problem comes from the script, if you see other errors you can  
> > tell me too.  
> > So :
> 
> > I'll send an SOS to the world  
> > I hope that someone gets my  
> > Message in a forum
> 
> > Thanks !

---

<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 20, 2012, 10:39am UTC](https://discuss.elastic.co/t/question-about-scripting/7378/4 "2012-04-20T10:39:26Z")

</div>

ctx is just a map that currently contain one value "\_source", which is  
another map containing all fileds in your document parsed into a map. So,

"script" : "ctx.\_source["tag"] = ["foo"]"

will create a new field called tag with value "foo" and

"script" : "ctx.\_source["tag"] += ["bar"]"

will create add another value "bar" to the filed.

You can combine these two operations together by checking if field already  
exists first:

"script" : "if(ctx.\_source["tag"]==null) { ctx.\_source["tag"] =  
["foo"]} else {ctx.\_source["tag"] += ["foo"]}"

On Friday, April 20, 2012 4:53:54 AM UTC-4, Jérome wrote:

> Oh, i'm trying but i d'ont understand what is ctx.\_source, mainly  
> "ctx".
> 
> On 19 avr, 18:56, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:
> 
> > I think in the update operation you should use ctx.\_source instead of  
> > \_fields.
> > 
> > On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:
> > 
> > > Hi,  
> > > I want for a test indexing data with 2 fields and after that, i want  
> > > add fields with "update".
> > 
> > > I've try :
> > 
> > > for($i=1; $i \< 4; $i++){  
> > > if($i == 1){  
> > > $result =  
> > > $es-\>index(  
> > > index  
> > > =\>  
> > > "toto",  
> > > type  
> > > =\>  
> > > "tata",  
> > > id  
> > > =\>  
> > > 1,  
> > > data  
> > > =\> {
> 
> name
> 
> > > =\> "big",
> 
> surname
> 
> > > =\> "muzzy"  
> > > },  
> > > );  
> > > }  
> > > else{  
> > > print "tag : ";  
> > > #name of the new tag  
> > > chomp($tag =  
> > > );
> > 
> > > ```
> > > $result =
> > > 
> > > ```
> > > 
> > > $es-\>update(  
> > > index  
> > > =\>  
> > > "toto",  
> > > type  
> > > =\>  
> > > "tata",  
> > > id  
> > > =\>  
> > > 1,
> > 
> > > ```
> > > script 
> > > 
> > > ```
> 
> =\>
> 
> > > "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> > > know how it's works  
> > > params  
> > > =\>  
> > > {$tag =\> 'ok'}  
> > > );  
> > > }  
> > > }
> > 
> > > My main problem comes from the script, if you see other errors you can  
> > > tell me too.  
> > > So :
> > 
> > > I'll send an SOS to the world  
> > > I hope that someone gets my  
> > > Message in a forum
> > 
> > > Thanks !
> > 
> > On Wednesday, April 18, 2012 9:20:20 AM UTC-4, Jérome wrote:
> > 
> > > Hi,  
> > > I want for a test indexing data with 2 fields and after that, i want  
> > > add fields with "update".
> > 
> > > I've try :
> > 
> > > for($i=1; $i \< 4; $i++){  
> > > if($i == 1){  
> > > $result =  
> > > $es-\>index(  
> > > index  
> > > =\>  
> > > "toto",  
> > > type  
> > > =\>  
> > > "tata",  
> > > id  
> > > =\>  
> > > 1,  
> > > data  
> > > =\> {
> 
> name
> 
> > > =\> "big",
> 
> surname
> 
> > > =\> "muzzy"  
> > > },  
> > > );  
> > > }  
> > > else{  
> > > print "tag : ";  
> > > #name of the new tag  
> > > chomp($tag =  
> > > );
> > 
> > > ```
> > > $result =
> > > 
> > > ```
> > > 
> > > $es-\>update(  
> > > index  
> > > =\>  
> > > "toto",  
> > > type  
> > > =\>  
> > > "tata",  
> > > id  
> > > =\>  
> > > 1,
> > 
> > > ```
> > > script 
> > > 
> > > ```
> 
> =\>
> 
> > > "\_fields[$tag].value+=[tag]", #Doesn't work, don't  
> > > know how it's works  
> > > params  
> > > =\>  
> > > {$tag =\> 'ok'}  
> > > );  
> > > }  
> > > }
> > 
> > > My main problem comes from the script, if you see other errors you can  
> > > tell me too.  
> > > So :
> > 
> > > I'll send an SOS to the world  
> > > I hope that someone gets my  
> > > Message in a forum
> > 
> > > Thanks !

---

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 23, 2012, 12:53pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/5 "2012-04-23T12:53:38Z")

</div>

Hi !  
First, thanks for explain Igor.

I've try the ctx.\_source but doesn't works.

I show you the entire script (little script just to test update  
function)

* * *

Script

* * *

#!/usr/bin/perl

use strict;  
use warnings;  
use ElasticSearch;

```
				my $es = ElasticSearch->new(
									        transport => 'http',

```

servers =\> 'localhost:9200',  
trace\_calls =\> 1,  
timeout =\> 30,  
max\_requests =\> 10\_000,

```
									        no_refresh => 0
										);

				my ($result, $tag);
				my $i;

				for($i=1; $i < 5; $i++){
					if($i == 1){
						$result = $es->index(
							index => "toto",
							type => "tata",
							id => 1,
							data => {
								name => "big",
								surname => "muzzy"
							},
						);
					}
					else{
						print "tag : ";
						chomp($tag = <STDIN>);

						$result = $es->update(
							index => "toto",
							type => "tata",
							id => 1,

							script => {"ctx._source[\"$tag\"].value=["foo"]"},
                                                            params

```

=\> {$tag =\> 'ok'}  
);  
}  
}

* * *

Error message

* * *

Odd number of elements in anonymous hash at ./testupdate.pl line 42,  
 line 1.

# [Mon Apr 23 14:49:55 2012] Protocol: http, Server:

193.51.160.124:9200  
curl -XPOST '[http://127.0.0.1:9200/toto/tata/1/\_update?pretty=1](http://127.0.0.1:9200/toto/tata/1/_update?pretty=1)' -d '  
{  
"params" : {  
"plop" : "ok"  
},  
"script" : {  
"ctx.\_source["plop"].value=["tags"]" : null  
}  
}  
'

# [Mon Apr 23 14:49:55 2012] Response:

# {

# "status" : 400,

# "error" : "ElasticSearchIllegalArgumentException[failed to exe

# \> cute script]; nested: CompileException[[Error: unterminated

# \> collection element]\n[Near : {... {ctx.\_source["plop"].val

# \> ue=["tags"]=null} ....}]\n

# \> ^\n[Line: 1, Column: 36]]; "

# }

[ERROR] \*\* ElasticSearch::Error::Request at /Library/Perl/5.10.0/  
ElasticSearch/Transport/HTTP.pm line 60 :  
ElasticSearchIllegalArgumentException[failed to execute script];  
nested: CompileException[[Error: unterminated collection element]  
[Near : {... {ctx.\_source["plop"].value=["tags"]=null} ....}]  
^  
[Line: 1, Column: 36]];

With vars:{  
'request' =\> {  
'post\_process' =\> undef,  
'qs' =\> {},  
'cmd' =\> '/toto/tata/1/\_update',  
'as\_json' =\> undef,  
'data' =\> {  
'params' =\> {  
'plop' =\> 'ok'  
},  
'script' =\> {  
'ctx.\_source["plop"].value=["tags"]' =\> undef  
}  
},  
'method' =\> 'POST'  
},  
'status\_code' =\> 400,  
'server' =\> '193.51.160.124:9200',  
'status\_msg' =\> 'Bad Request'  
}

I don't understand the problem...

Jerome

---

<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 23, 2012, 1:04pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/6 "2012-04-23T13:04:03Z")

</div>

I think the problem is caused by { } around script text. It should be

script =\> "ctx.\_source["$tag"].value=["foo"]"

On Monday, April 23, 2012 8:53:38 AM UTC-4, Jérome wrote:

> Hi !  
> First, thanks for explain Igor.
> 
> I've try the ctx.\_source but doesn't works.
> 
> I show you the entire script (little script just to test update  
> function)
> 
> * * *
> 
> Script
> 
> * * *
> 
> #!/usr/bin/perl
> 
> use strict;  
> use warnings;  
> use Elasticsearch;
> 
> ```
> my $es = ElasticSearch->new( 
>                                                                              
> transport => 'http', 
> 
> ```
> 
> servers =\> 'localhost:9200',
> 
> ```
> trace_calls => 1, 
>                                                                              
> timeout => 30, 
>                                                                              
> max_requests => 10_000, 
> 
>                                                                              
> no_refresh => 0 
> ); 
> 
> my ($result, $tag); 
> my $i; 
> 
> for($i=1; $i < 5; $i++){ 
> if($i == 1){ 
> $result = 
> 
> ```
> 
> $es-\>index(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,  
> data =\> {  
> name  
> =\> "big",  
> surname  
> =\> "muzzy"  
> },  
> );  
> }  
> else{  
> print "tag : ";  
> chomp($tag =  
> );
> 
> ```
> $result = 
> 
> ```
> 
> $es-\>update(  
> index =\>  
> "toto",  
> type =\>  
> "tata",  
> id =\>  
> 1,
> 
> ```
> script => 
> 
> ```
> 
> {"ctx.\_source["$tag"].value=["foo"]"},  
> params  
> =\> {$tag =\> 'ok'}  
> );  
> }  
> }
> 
> * * *
> 
> Error message
> 
> * * *
> 
> Odd number of elements in anonymous hash at ./testupdate.pl line 42,  
> line 1.
> 
> # [Mon Apr 23 14:49:55 2012] Protocol: http, Server:
> 
> 193.51.160.124:9200  
> curl -XPOST '[http://127.0.0.1:9200/toto/tata/1/\_update?pretty=1](http://127.0.0.1:9200/toto/tata/1/_update?pretty=1)' -d '  
> {  
> "params" : {  
> "plop" : "ok"  
> },  
> "script" : {  
> "ctx.\_source["plop"].value=["tags"]" : null  
> }  
> }  
> '
> 
> # [Mon Apr 23 14:49:55 2012] Response:
> 
> # {
> 
> # "status" : 400,
> 
> # "error" : "ElasticSearchIllegalArgumentException[failed to exe
> 
> # \> cute script]; nested: CompileException[[Error: unterminated
> 
> # \> collection element]\n[Near : {... {ctx.\_source["plop"].val
> 
> # \> ue=["tags"]=null} ....}]\n
> 
> # \> ^\n[Line: 1, Column: 36]]; "
> 
> # }
> 
> [ERROR] \*\* Elasticsearch::Error::Request at /Library/Perl/5.10.0/  
> Elasticsearch/Transport/HTTP.pm line 60 :  
> ElasticSearchIllegalArgumentException[failed to execute script];  
> nested: CompileException[[Error: unterminated collection element]  
> [Near : {... {ctx.\_source["plop"].value=["tags"]=null} ....}]  
> ^  
> [Line: 1, Column: 36]];
> 
> With vars:{  
> 'request' =\> {  
> 'post\_process' =\> undef,  
> 'qs' =\> {},  
> 'cmd' =\> '/toto/tata/1/\_update',  
> 'as\_json' =\> undef,  
> 'data' =\> {  
> 'params' =\> {  
> 'plop' =\> 'ok'  
> },  
> 'script' =\> {  
> 'ctx.\_source["plop"].value=["tags"]' =\> undef  
> }  
> },  
> 'method' =\> 'POST'  
> },  
> 'status\_code' =\> 400,  
> 'server' =\> '193.51.160.124:9200',  
> 'status\_msg' =\> 'Bad Request'  
> }
> 
> I don't understand the problem...
> 
> Jerome

---

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 23, 2012, 1:32pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/7 "2012-04-23T13:32:17Z")

</div>

Yes it works !  
Really really thank you !

Jerome

On 23 avr, 15:04, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:

> I think the problem is caused by { } around script text. It should be
> 
> script =\> "ctx.\_source["$tag"].value=["foo"]"
> 
> On Monday, April 23, 2012 8:53:38 AM UTC-4, Jérome wrote:
> 
> > Hi !  
> > First, thanks for explain Igor.
> 
> > I've try the ctx.\_source but doesn't works.
> 
> > I show you the entire script (little script just to test update  
> > function)
> 
> > * * *
> > 
> > Script
> > 
> > * * *
> > 
> > #!/usr/bin/perl
> 
> > use strict;  
> > use warnings;  
> > use Elasticsearch;
> 
> > ```
> > my $es = ElasticSearch->new(
> > 
> > ```
> 
> > ```
> > transport => 'http',
> > 
> > ```
> 
> > servers =\> 'localhost:9200',
> 
> > ```
> > trace_calls => 1,
> > 
> > ```
> 
> > ```
> > timeout => 30,
> > 
> > ```
> 
> > ```
> > max_requests => 10_000,
> > 
> > ```
> 
> > ```
> > no_refresh => 0
> > );
> > 
> > ```
> 
> > ```
> > my ($result, $tag);
> > my $i;
> > 
> > ```
> 
> > ```
> > for($i=1; $i < 5; $i++){
> > if($i == 1){
> > $result =
> > 
> > ```
> > 
> > $es-\>index(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,  
> > data =\> {  
> > name  
> > =\> "big",  
> > surname  
> > =\> "muzzy"  
> > },  
> > );  
> > }  
> > else{  
> > print "tag : ";  
> > chomp($tag =  
> > );
> 
> > ```
> > $result =
> > 
> > ```
> > 
> > $es-\>update(  
> > index =\>  
> > "toto",  
> > type =\>  
> > "tata",  
> > id =\>  
> > 1,
> 
> > ```
> > script =>
> > 
> > ```
> > 
> > {"ctx.\_source["$tag"].value=["foo"]"},  
> > params  
> > =\> {$tag =\> 'ok'}  
> > );  
> > }  
> > }
> 
> > * * *
> > 
> > Error message
> > 
> > * * *
> > 
> > Odd number of elements in anonymous hash at ./testupdate.pl line 42,  
> > line 1.
> > 
> > # [Mon Apr 23 14:49:55 2012] Protocol: http, Server:
> > 
> > 193.51.160.124:9200  
> > curl -XPOST '[http://127.0.0.1:9200/toto/tata/1/\_update?pretty=1](http://127.0.0.1:9200/toto/tata/1/_update?pretty=1)' -d '  
> > {  
> > "params" : {  
> > "plop" : "ok"  
> > },  
> > "script" : {  
> > "ctx.\_source["plop"].value=["tags"]" : null  
> > }  
> > }  
> > '
> 
> > # [Mon Apr 23 14:49:55 2012] Response:
> > 
> > # {
> > 
> > # "status" : 400,
> > 
> > # "error" : "ElasticSearchIllegalArgumentException[failed to exe
> > 
> > # \> cute script]; nested: CompileException[[Error: unterminated
> > 
> > # \> collection element]\n[Near : {... {ctx.\_source["plop"].val
> > 
> > # \> ue=["tags"]=null} ....}]\n
> > 
> > # \> ^\n[Line: 1, Column: 36]]; "
> > 
> > # }
> 
> > [ERROR] \*\* Elasticsearch::Error::Request at /Library/Perl/5.10.0/  
> > Elasticsearch/Transport/HTTP.pm line 60 :  
> > ElasticSearchIllegalArgumentException[failed to execute script];  
> > nested: CompileException[[Error: unterminated collection element]  
> > [Near : {... {ctx.\_source["plop"].value=["tags"]=null} ....}]  
> > ^  
> > [Line: 1, Column: 36]];
> 
> > With vars:{  
> > 'request' =\> {  
> > 'post\_process' =\> undef,  
> > 'qs' =\> {},  
> > 'cmd' =\> '/toto/tata/1/\_update',  
> > 'as\_json' =\> undef,  
> > 'data' =\> {  
> > 'params' =\> {  
> > 'plop' =\> 'ok'  
> > },  
> > 'script' =\> {  
> > 'ctx.\_source["plop"].value=["tags"]' =\> undef  
> > }  
> > },  
> > 'method' =\> 'POST'  
> > },  
> > 'status\_code' =\> 400,  
> > 'server' =\> '193.51.160.124:9200',  
> > 'status\_msg' =\> 'Bad Request'  
> > }
> 
> > I don't understand the problem...
> 
> > Jerome

---

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 23, 2012, 1:32pm UTC](https://discuss.elastic.co/t/question-about-scripting/7378/8 "2012-04-23T13:32:55Z")

</div>

SOLVED

---

<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, 3:31am UTC](https://discuss.elastic.co/t/question-about-scripting/7378/9 "2017-07-06T03:31:22Z")

</div>


