1

I'm trying to rename data that is in this shape:

enter image description here

using this:

POST r_xair_signals-2020-06/_update/2020-06-15T22:23:00Z_-1344027716
{
  "doc" : {
        "Customer ImpactedNested" : "CustomerImpactedNested"
    }
}

But I'm getting:

"type": "mapper_parsing_exception",
    "reason": "object mapping for [Customer ImpactedNested] tried to parse field [Customer ImpactedNested] as object, but found a concrete value"

I've confirmed the type of Customer ImpactedNested is nested. I see info online about people getting this error, but not when trying to rename, and don't see any solutions. I saw one article that indicated it occurred when the new name conflicted with an existing name. So, tried renaming to CustomerImpactedNested11111 as a test (sure to be unique), but same result.

Any ideas would be great!

  • 1
    I found a way around this problem, and I haven't been able to test your answer yet. Plan to by the end of the week, though. And thank you for answering! – redmondcoffehead Jun 25 '20 at 15:09

1 Answers1

2

There are two problems actually.

  1. Your query is not renaming the field.
  2. Renaming the nested field

What is happening actually in the following line from the question:

POST r_xair_signals-2020-06/_update/2020-06-15T22:23:00Z_-1344027716
{
  "doc" : {
        "Customer ImpactedNested" : "CustomerImpactedNested"
    }
}

It updates column value of column=Customer ImpactedNested to CustomerImpactedNested document whose id is 2020-06-15T22:23:00Z_-1344027716.

And Customer ImpactedNested is a nested object and you are trying to set a string value to the nested object field. Hence you are getting the error. Refer this

Coming to your original problem, you need to do this via reindex. Refer this, this also

POST _reindex
{
  "source": {
    "index": "r_xair_signals-2020-06"
  },
  "dest": {
    "index": "<some_new_index_name>"
  },
  "script": {
    "inline": """ctx._source['CustomerImpactedNested'] = ctx._source.remove("Customer ImpactedNested")"""
  }
}

Please try the above and let me know for errors as I didn't try the above query.

Gibbs
  • 21,904
  • 13
  • 74
  • 138
  • The above worked after I changed the destination index to a different index. When I tried it as it was, an error about not being able to reindex into the index being read from. There is an explanation of why from an elastic engineer: "We chose not to let reindex index back to the same index because for the most part it isn't the right thing to do. . . ." It is a comment from nik9000 on Feb 9, 2017 here: https://github.com/elastic/elasticsearch/issues/23033. There is more in the comment than I'm including here. – redmondcoffehead Jun 27 '20 at 16:04