# Reindexing - Null pointer exception while attempting to 'move' field into an object

**URL:** <https://discuss.elastic.co/t/reindexing-null-pointer-exception-while-attempting-to-move-field-into-an-object/93622>\
**Category:** Elasticsearch\
**Created:** [July 18, 2017, 4:13pm UTC](https://discuss.elastic.co/t/reindexing-null-pointer-exception-while-attempting-to-move-field-into-an-object/93622 "2017-07-18T16:13:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ttrmw](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@ttrmw](https://discuss.elastic.co/u/ttrmw)\
**Post date:** [July 18, 2017, 4:13pm UTC](https://discuss.elastic.co/t/reindexing-null-pointer-exception-while-attempting-to-move-field-into-an-object/93622/1 "2017-07-18T16:13:10Z")

</div>

Hey,

I'm attempting to change some mappings and reindex, whilst in the process changing my data's structure. My request looks like:

```
2017-07-18 16:56:48 +0100: POST http://127.0.0.1:9201/_reindex [status:500, request:0.009s, query:N/A]

2017-07-18 16:56:48 +0100: > {
    "source":{
        "index":"my_index"
    },
    "dest":{
        "index":"my_new_index"
    },
    "script":{
        "inline":"ctx._source.review.checked = ctx._source.remove(\"checked\"); ctx._source.review.false_positive = ctx._source.remove(\"false_positive\")"
    }
}

```

And I get:

```
[500] {"error":{
    "root_cause":[{
        "type":"script_exception",
        "reason":"runtime error",
        "script_stack":[{
            "ctx._source.review.checked = ctx._source.remove(\"checked\"); ",
            " ^---- HERE"],
            "script":"ctx._source.review.checked = ctx._source.remove(\"checked\"); ctx._source.review.false_positive = ctx._source.remove(\"false_positive\")",
            "lang":"painless"
        }],
        "type":"script_exception",
        "reason":"runtime error",
        "script_stack":[
            "ctx._source.review.checked = ctx._source.remove(\"checked\"); ",
            " ^---- HERE"
        ],
        "script":"ctx._source.review.checked = ctx._source.remove(\"checked\"); ctx._source.review.false_positive = ctx._source.remove(\"false_positive\")",
        "lang":"painless",
        "caused_by":{
            "type":"null_pointer_exception",
            "reason":null
        }
    },
    "status":500
}

```

My mapping in the target index is (forgive the ruby hash syntax):

```
{"my-index"=>
  {"mappings"=>
    {"mydoc"=>
      {"properties"=>
         "checked"=>{"type"=>"boolean"},
         "false_positive"=>{"type"=>"boolean"},
         "review"=>
          {"properties"=>
            {"checked"=>{"type"=>"boolean"},
             "false_positive"=>{"type"=>"boolean"},
             "reviewer"=>
              {"properties"=>
                {"email"=>
                  {"type"=>"text",
                   "fields"=>
                    {"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}},
                 "id"=>
                  {"type"=>"text",
                  "fields"=>
                    {"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}},
             "type"=>
              {"type"=>"text",
               "fields"=>
                {"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}},\
                #...........

```

And in the source, lacks the 'review' object'. Any pointers on how to debug this? The error message is kind of opaque... Is it called \_source that's breaking the painless script, or calling review (which wouldn't be present in the source index, I guess, since that's the point of the reindexing).

Thanks in advance!

---

<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 15, 2017, 4:13pm UTC](https://discuss.elastic.co/t/reindexing-null-pointer-exception-while-attempting-to-move-field-into-an-object/93622/2 "2017-08-15T16:13:15Z")

</div>

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