# Update using script for entire index

**URL:** <https://discuss.elastic.co/t/update-using-script-for-entire-index/8230>\
**Category:** Elasticsearch\
**Created:** [June 26, 2012, 6:16pm UTC](https://discuss.elastic.co/t/update-using-script-for-entire-index/8230 "2012-06-26T18:16:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Nigam\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashish_nigam_2/32/2804_2.png) [@Ashish\_Nigam\_2](https://discuss.elastic.co/u/Ashish_Nigam_2)\
**Post date:** [June 26, 2012, 6:16pm UTC](https://discuss.elastic.co/t/update-using-script-for-entire-index/8230/1 "2012-06-26T18:16:56Z")

</div>

Hi,  
I am trying to perform simple update via this call -

curl -XPOST 'localhost:9200/testindex\_2/eventsummarydata/\_update' -d '{  
"script" : "ctx.\_source.cspId == 9700 ? ctx.\_source.cspId = 97 : ctx.op = "none""  
}'

My goal is to update an integer field if its value is 9700 to a new value of 97. This call does not work till I specify id of the document.  
So this call will work -

curl -XPOST 'localhost:9200/testindex\_2/eventsummarydata/10999/\_update' -d '{  
"script" : "ctx.\_source.cspId == 9700 ? ctx.\_source.cspId = 97 : ctx.op = "none""  
}'

Is it not possible to update all documents within an index without providing explicit id?  
If there is, please let me know the right way.

Thanks  
Ashish

---

<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:22am UTC](https://discuss.elastic.co/t/update-using-script-for-entire-index/8230/2 "2017-07-06T03:22:25Z")

</div>


