# Update api

**URL:** https://discuss.elastic.co/t/update-api/11561
**Category:** Elasticsearch
**Created:** [April 12, 2013, 9:41am UTC](https://discuss.elastic.co/t/update-api/11561 "2013-04-12T09:41:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kuwar\_sahani\_2](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kuwar\_sahani\_2](https://discuss.elastic.co/u/kuwar_sahani_2)
#### Post date: [April 12, 2013, 9:41am UTC](https://discuss.elastic.co/t/update-api/11561/1 "2013-04-12T09:41:28Z")

</div>

I have this index

curl -XPUT "[http://10.118.192.145:9200/test/type1/1](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](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](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:41am UTC](https://discuss.elastic.co/t/update-api/11561/2 "2017-07-06T02:41:26Z")

</div>


