# Script update : NOOP when script does not modify document?

**URL:** <https://discuss.elastic.co/t/script-update-noop-when-script-does-not-modify-document/222724>\
**Category:** Elasticsearch\
**Created:** [March 9, 2020, 2:14pm UTC](https://discuss.elastic.co/t/script-update-noop-when-script-does-not-modify-document/222724 "2020-03-09T14:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deslauriersp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deslauriersp/32/47685_2.png) [@deslauriersp](https://discuss.elastic.co/u/deslauriersp)\
**Post date:** [March 9, 2020, 2:14pm UTC](https://discuss.elastic.co/t/script-update-noop-when-script-does-not-modify-document/222724/1 "2020-03-09T14:14:05Z")

</div>

I need to update a large number of documents. Technically this update (should) generate a lot of noops.

The script checks a condition on the \_source, and only modify the \_source under certain conditions. I cannot check this condition in the query, as the **value I am checking is only contained in the source**.

It seems that an update "by script" always result in an update, regardless if the script updates the "\_source" or not.

After observing this, I tried a little test I have used a script that does nothing, but I can see the "version" of my doc going up.

Is this normal?  
Using V.76.0

```
POST http://127.0.0.1:9200/order/_update/1
{
    "script" : {
    "source": "def aVar = \"doNothing\";",
     "lang": "painless"
    },
    
    "upsert" : {
	    "orderNo":"1234",
	    "clients" : [
	    		{"clientId":"p1","firstName":"john","lastName":"doe"},
	    		{"clientId":"p2","firstName":"will","lastName":"smith"}
	    ]
     }
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 12, 2020, 9:59am UTC](https://discuss.elastic.co/t/script-update-noop-when-script-does-not-modify-document/222724/2 "2020-03-12T09:59:14Z")

</div>

Hey,

You can control this in the script execution by yourself, by setting

```auto
ctx.op = 'noop'

```

hope this helps!

--Alex

---

<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:** [April 9, 2020, 9:59am UTC](https://discuss.elastic.co/t/script-update-noop-when-script-does-not-modify-document/222724/3 "2020-04-09T09:59:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
