# Painless max script size limit?

**URL:** <https://discuss.elastic.co/t/painless-max-script-size-limit/289707>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 19, 2021, 3:44pm UTC](https://discuss.elastic.co/t/painless-max-script-size-limit/289707 "2021-11-19T15:44:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_McGovern](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_mcgovern/32/90131_2.png) [@Matt\_McGovern](https://discuss.elastic.co/u/Matt_McGovern)\
**Post date:** [November 19, 2021, 3:44pm UTC](https://discuss.elastic.co/t/painless-max-script-size-limit/289707/1 "2021-11-19T15:44:03Z")

</div>

It used to be that the total size of a painless stored script was 16384, from a hard-coded system limit I've seen referenced before as MAXIMUM\_SOURCE\_LENGTH = 16384.

I've run into the limit within the last few years and am wondering what the limit is now since we've upgraded (currently at 7.7.1). Is there a setting that we can check and/or set for this?

Also, I've seen recommendations for large stored scripts written in painless to be done instead in a plugin. Can anyone show me any documentation for writing such a plugin?

We have over a thousand watchers all running the same very large painless stored script which has a lot of functionality, so if making this into a plugin is recommended I need to investigate it.

-Matt

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [November 19, 2021, 5:28pm UTC](https://discuss.elastic.co/t/painless-max-script-size-limit/289707/2 "2021-11-19T17:28:52Z")

</div>

The size of scripts is limited to 65,535 bytes. You can change the value of `script.max_size_in_bytes` to increase that soft limit in you ES cluster settings.  
More info can be found on this [link](https://github.com/elastic/elasticsearch/blob/master/docs/reference/scripting/using.asciidoc#modules-scripting-engine).

---

<div class="post-metadata">

**Author:** ![Matt\_McGovern](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_mcgovern/32/90131_2.png) [@Matt\_McGovern](https://discuss.elastic.co/u/Matt_McGovern)\
**Post date:** [November 19, 2021, 5:58pm UTC](https://discuss.elastic.co/t/painless-max-script-size-limit/289707/3 "2021-11-19T17:58:14Z")

</div>

Is that the same setting as MAXIMUM\_SOURCE\_LENGTH, or for cache settings? I've seen both referenced as different things.

---

<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:** [December 17, 2021, 5:59pm UTC](https://discuss.elastic.co/t/painless-max-script-size-limit/289707/4 "2021-12-17T17:59:12Z")

</div>

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