Update api

I have this index

curl -XPUT "" -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 "" -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.