# Script query started to fail suddenly

**URL:** <https://discuss.elastic.co/t/script-query-started-to-fail-suddenly/313985>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [September 8, 2022, 11:06am UTC](https://discuss.elastic.co/t/script-query-started-to-fail-suddenly/313985 "2022-09-08T11:06:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richa\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richa_b/32/50906_2.png) [@Richa\_B](https://discuss.elastic.co/u/Richa_B)\
**Post date:** [September 8, 2022, 11:06am UTC](https://discuss.elastic.co/t/script-query-started-to-fail-suddenly/313985/1 "2022-09-08T11:06:31Z")

</div>

We have had this query for a long time

```auto
{
  "size": 50,
  "query": {
   "match_all": {}
  },
  "version": false,
  "seq_no_primary_term": false,
  
  "sort": [
    {
      "_script": {
        "script": {
          "source": "(doc[params.f].size() != 0) ? (params.m['' + doc[params.f].value] ?: params.o): params.o",
          "lang": "painless",
          "params": {
            "f": "scoreSerial",
            "m": {
              "0": "UNDEFINED",
              "1": "FRUSTRATED",
              "2": "TOLERATED",
              "3": "SATISFIED"
            },
            "o": "ZZZZZ"
          }
        },
        "type": "string",
        "order": "asc"
      }
    }
  ]
} 

```

This suddenly stopped working with the error

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "bootstrap_method_error",
        "reason" : "bootstrap_method_error: CallSite bootstrap method initialization exception"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "visit-global-standard-w2022.31",
        "node" : "olbLlZh7RYuwaf5S-B9v8g",
        "reason" : {
          "type" : "script_exception",
          "reason" : "runtime error",
          "script_stack" : [
            "(doc[params.f].size() != 0) ? (params.m['' + doc[params.f].value] ?: params.o): params.o",
            " ^---- HERE"
          ],
          "script" : "(doc[params.f].size() != 0) ? (params.m['' + doc[params.f].value] ?: params.o): params.o",
          "lang" : "painless",
          "position" : {
            "offset" : 58,
            "start" : 0,
            "end" : 88
          },
          "caused_by" : {
            "type" : "bootstrap_method_error",
            "reason" : "bootstrap_method_error: CallSite bootstrap method initialization exception"
          }
        }
      }
    ],
    "caused_by" : {
      "type" : "bootstrap_method_error",
      "reason" : "bootstrap_method_error: CallSite bootstrap method initialization exception"
    }
  },
  "status" : 400
}

```

It was working for more than 3 years. We are now on 7.10 (for more than 6 months, when the above script was working) ES version. But suddenly it started to fail.  
The strange thing is that it is not happening in all environments. Is it some java version related or something else? We can not also reproduce this locally.

---

<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:** [October 6, 2022, 11:07am UTC](https://discuss.elastic.co/t/script-query-started-to-fail-suddenly/313985/2 "2022-10-06T11:07:29Z")

</div>

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