# Migration to Elasticsearch 6 : request with script and params not working

**URL:** <https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [January 17, 2022, 11:10am UTC](https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570 "2022-01-17T11:10:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drapej](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drapej/32/100399_2.png) [@drapej](https://discuss.elastic.co/u/drapej)\
**Post date:** [January 17, 2022, 11:10am UTC](https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570/1 "2022-01-17T11:10:30Z")

</div>

Hello,  
I am migrating my Elasticsearch from v5.16 to 6.8 (and after to 7.16) but I have some problem with this type of request (see below) : using params['\_source'] in a script  
I don't understand why. I didn't find any breakings changes in the documentation. Can you please help me ?  
Thanks

```json
{
  "query": {
    "bool": {
      "must": [
        { "match": { "closed": "false" }
        },
        {
          "script": {
            "script": {
              "source": "(params['_source']['evts'] !== null) && (params['_source']['evts']).length > 0",
              "lang": "painless"
            }
          }
        }
      ]
    }
  }}

```

The response

```json
{
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 2,
    "skipped": 0,
    "failed": 3,
    "failures": [
      {
        "shard": 1,
        "index": "myIndex",
        "node": "XXX",
        "reason": {
          "type": "script_exception",
          "reason": "runtime error",
          "script_stack": [
            "(params['_source']['evts'] !== null) && (params['_source']['evts']).length > 0",
            " ^---- HERE"
          ],
          "script": "(params['_source']['evts'] !== null) && (params['_source']['piecesJointes']).length > 0",
          "lang": "painless",
          "caused_by": {
            "type": "null_pointer_exception",
            "reason": "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null"
          }
        }
      }
    ]
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

```

---

<div class="post-metadata">

**Author:** ![Jack\_Conradson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_conradson/32/47236_2.png) [@Jack\_Conradson](https://discuss.elastic.co/u/Jack_Conradson)\
**Post date:** [January 19, 2022, 5:37pm UTC](https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570/2 "2022-01-19T17:37:18Z")

</div>

Hi @drapej,

Source access was removed from several different script contexts including filter scripts transitioning from 5.x to 6.x. At the time our philosophy was to ensure good performance, so we felt that allowing source access in filter/search scripts had hidden performance costs we could not easily make users aware of. Our suggested workaround is to index any data required as part of the documents. If this is not possible when you upgrade to 7.x runtime fields are available that could replicate this behavior, so you could remove the scripts to upgrade to 6.x and then add runtime fields to replace them as part of 7.x.

---

<div class="post-metadata">

**Author:** ![drapej](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drapej/32/100399_2.png) [@drapej](https://discuss.elastic.co/u/drapej)\
**Post date:** [January 20, 2022, 10:50am UTC](https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570/3 "2022-01-20T10:50:04Z")

</div>

Ok thanks a lot. I will do that

---

<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:** [February 17, 2022, 10:50am UTC](https://discuss.elastic.co/t/migration-to-elasticsearch-6-request-with-script-and-params-not-working/294570/4 "2022-02-17T10:50:21Z")

</div>

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