# Too many dynamic script compilations within max

**URL:** <https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793>\
**Category:** Elasticsearch\
**Created:** [October 16, 2019, 9:13am UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793 "2019-10-16T09:13:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvanegmond](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rvanegmond](https://discuss.elastic.co/u/rvanegmond)\
**Post date:** [October 16, 2019, 9:13am UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793/1 "2019-10-16T09:13:17Z")

</div>

I know there are some posts about this but they didn't completely awnser my question.

I'm processing millions of data in terms of documents which need to be updated by a "where query" using two fields. The data in the query is coming from an external system. The posts I perform look like the one below, of course the values change.

```
{
   "query" : {
   "bool" : {
       "must" : [
         {
           "term" : {
           "path.raw" : {
           "value" : "d:/kibana-7.3.0/x-pack/legacy/plugins/siem/node_modules/lodash/fp/takeRight.js"
          }
        }
      },
      {
      "range" : {
        "file.modified.date" : {
          "gte" : "2019-07-24T16:58:46Z",
          "lte" : "2019-07-24T16:58:46Z"
          }
        }
      }
  ]
}
},
"script" : {
   "source" : "ctx._source.file.hash = '0A98E2919C1776463A3AD3768663987F'",
    "lang" : "painless"
}

```

}

First of all is this the correct way to do updates like this or are there better methods? I'm already using bulk when I know the actual \_id the document to update.

Is it safe the change the max setting? And if not, then how should I perform something like this.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![rvanegmond](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rvanegmond](https://discuss.elastic.co/u/rvanegmond)\
**Post date:** [October 16, 2019, 11:43am UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793/2 "2019-10-16T11:43:14Z")

</div>

I managed to get around the exception by using params. The question remains is this the best and fastest way to do this kind of updates?

---

<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:** [October 16, 2019, 12:50pm UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793/3 "2019-10-16T12:50:58Z")

</div>

Hey,

using params will solve your script issue. Alternatively you could also use a pipeline like mentioned in the [update by query](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/docs-update-by-query.html) docs (if you are using update by query, not a hundred percent sure).

--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:** [November 13, 2019, 12:51pm UTC](https://discuss.elastic.co/t/too-many-dynamic-script-compilations-within-max/203793/4 "2019-11-13T12:51:05Z")

</div>

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