# ElasticSerach API - update by query script params null\_pointer\_exception

**URL:** <https://discuss.elastic.co/t/elasticserach-api-update-by-query-script-params-null-pointer-exception/280325>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [August 3, 2021, 2:02pm UTC](https://discuss.elastic.co/t/elasticserach-api-update-by-query-script-params-null-pointer-exception/280325 "2021-08-03T14:02:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Savas12.01](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Savas12.01](https://discuss.elastic.co/u/Savas12.01)\
**Post date:** [August 3, 2021, 2:02pm UTC](https://discuss.elastic.co/t/elasticserach-api-update-by-query-script-params-null-pointer-exception/280325/1 "2021-08-03T14:02:06Z")

</div>

I am new to the ElasticSearch and am i trying to make use of the \_update\_by\_query route. I am sending this body:

```auto
{
"query": {
    "match": {
        "id": "fdfsfsfs-058f-437d-bc52-473808ba61c2"
    }
},
"script": {
    "inline": "ctx._source.addresses.add(params.data)",
    "params": {
        "data": {
            "street": "Road",
            "number": 15,
            "county": "WWW"
        }
    }
}

```

but I get the following response:

```auto
{
"error": {
    "root_cause": [
        {
            "type": "script_exception",
            "reason": "runtime error",
            "script_stack": [
                "ctx._source.addresses.add(params.data)",
                " ^---- HERE"
            ],
            "script": "ctx._source.addresses.add(params.data)",
            "lang": "painless",
            "position": {
                "offset": 30,
                "start": 0,
                "end": 36
            }
        }
    ],
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
        "ctx._source.addresses.add(params.data)",
        " ^---- HERE"
    ],
    "script": "ctx._source.addresses.add(params.data)",
    "lang": "painless",
    "position": {
        "offset": 30,
        "start": 0,
        "end": 36
    },
    "caused_by": {
        "type": "null_pointer_exception",
        "reason": null
    }
},
"status": 400
}

```

I don't know what could be the error, since I do pass my params and they are inside the "script" object. Does anyone have an idea of what could be wrong?

Thank you very much in advance!

---

<div class="post-metadata">

**Author:** ![Savas12.01](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Savas12.01](https://discuss.elastic.co/u/Savas12.01)\
**Post date:** [August 3, 2021, 2:18pm UTC](https://discuss.elastic.co/t/elasticserach-api-update-by-query-script-params-null-pointer-exception/280325/2 "2021-08-03T14:18:41Z")

</div>

The problem was that I was using "match", instead of "term", so my query returned multiple results.

---

<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:** [August 31, 2021, 2:19pm UTC](https://discuss.elastic.co/t/elasticserach-api-update-by-query-script-params-null-pointer-exception/280325/3 "2021-08-31T14:19:23Z")

</div>

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