# Update a filed with script, there's error caused by "unsupported\_operation\_exception: null"

**URL:** https://discuss.elastic.co/t/update-a-filed-with-script-theres-error-caused-by-unsupported-operation-exception-null/316491
**Category:** Elasticsearch
**Tags:** painless
**Created:** [October 13, 2022, 6:19am UTC](https://discuss.elastic.co/t/update-a-filed-with-script-theres-error-caused-by-unsupported-operation-exception-null/316491 "2022-10-13T06:19:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chocolateBlack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chocolateblack/32/112000_2.png) [@chocolateBlack](https://discuss.elastic.co/u/chocolateBlack)
#### Post date: [October 13, 2022, 6:19am UTC](https://discuss.elastic.co/t/update-a-filed-with-script-theres-error-caused-by-unsupported-operation-exception-null/316491/1 "2022-10-13T06:19:55Z")

</div>

using script update object field , unsupported\_operation\_exception occors.  
elasticsearch version 7.10.

```auto
PUT script_test/
{
    "mappings" : {
      "dynamic" : "strict",
      "properties" : {
        "batch_name" : {
          "type" : "keyword"
        },
        "course_source_jx_cnt" : {
          "dynamic" : "true",
          "properties" : {
            "course_total_cnt" : {
              "type" : "long"
            }
          }
        }
      }
    },
    "settings" : {
      "number_of_shards": 4, 
      "number_of_replicas": 0,
      "refresh_interval": "20s"
    }
}

DELETE script_test/_doc/3

POST script_test/_create/3
{
  "batch_name" : "app_rby_landing_middle"
}

GET script_test/_doc/3

POST script_test/_update/3
{
  "script": {
    "lang": "painless",
    "source": "if(ctx._source.course_source_jx_cnt == null){ctx._source.course_source_jx_cnt = params.exam_answer_default;} ctx._source.course_source_jx_cnt.course_total_cnt=params.course_total_cnt ", 
    "params": {"exam_answer_default":{}}
  }
}

```

errors:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "failed to execute script"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "failed to execute script",
    "caused_by" : {
      "type" : "script_exception",
      "reason" : "runtime error",
      "script_stack" : [
        "java.base/java.util.AbstractMap.put(AbstractMap.java:209)",
        "ctx._source.course_source_jx_cnt.course_total_cnt=params.course_total_cnt ",
        " ^---- HERE"
      ],
      "script" : "if(ctx._source.course_source_jx_cnt == null){ctx._source.course_source_jx_cnt = params.exam_answer_default;} ctx._source.course_source_jx_cnt.course_total_cnt=params.course_total_cnt ",
      "lang" : "painless",
      "position" : {
        "offset" : 142,
        "start" : 110,
        "end" : 184
      },
      "caused_by" : {
        "type" : "unsupported_operation_exception",
        "reason" : "unsupported_operation_exception: null"
      }
    }
  },
  "status" : 400
}

```

---

<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 13, 2022, 6:19am UTC](https://discuss.elastic.co/t/update-a-filed-with-script-theres-error-caused-by-unsupported-operation-exception-null/316491/2 "2022-10-13T06:19:56Z")

</div>

elasticsearch version 7.10 is [EOL](https://www.elastic.co/support/eol) and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

---

<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 10, 2022, 6:20am UTC](https://discuss.elastic.co/t/update-a-filed-with-script-theres-error-caused-by-unsupported-operation-exception-null/316491/3 "2022-11-10T06:20:34Z")

</div>

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