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

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!

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