Copy field and convert to lowercase

Hi There,
in all of my indices i have a field that i want to copy to a new field and convert it to lowercase.

Copying was easy:

    POST /INDEX-2018.06.07/_update_by_query?conflicts=proceed&refresh=true
{
    "query" : {
        "match_all" : {}
    },
    "script" : "ctx._source.fieldB_norm = ctx._source.fieldA;"
}

Unfortunately, converting to lowercase didn't worked.

I did in a second step:

POST /INDEX-2018.06.07/_update_by_query?conflicts=proceed&refresh=true
{
    "query" : {
        "match_all" : {}
    },
    "script" : "ctx._source.fieldB = ctx._source.fieldB.toLowerCase();"
}

And got this error message:

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "ctx._source.jv_keyword_search_norm = ctx._source.fieldB.toLowerCase();",
          "                                                       ^---- HERE"
        ],
        "script": "ctx._source.fieldB_norm = ctx._source.fieldB.toLowerCase();",
        "lang": "painless"
      }
    ],
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx._source.fieldB_norm = ctx._source.fieldB.toLowerCase();",
      "                                            ^---- HERE"
    ],
    "script": "ctx._source.fieldB_norm = ctx._source.fieldB.toLowerCase();",
    "lang": "painless",
    "caused_by": {
      "type": "null_pointer_exception",
      "reason": null
    }
  },
  "status": 500
}

Any Ideas how to do this?
I would be happy if i dont need to reindex everything :slight_smile:

I've been able to solve this by myself with updating each entry manually using a php script :slight_smile:
close pls

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