Update api

I have this index

curl -XPUT "http://10.118.192.145:9200/test/type1/1" -d '{
"tags" : ["red","blue"]
}'

want to perform an update like which checks for a tag in the tags field.if
it exists, do nothing else add.

i'am using this query:

curl -XPOST "http://10.118.192.145:9200/test/type1/1/_update" -d '{
"script" : "ctx._source.tags.contains(tag) ? ctx.op = "none" :
ctx._source.tags += tag",
"params" : {
"tag" : "Orange"
}
}'
the version gets updated but the tag is not being inserted.
Any suggestions? is there an alternate to achieve this.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.