Combine two nested text fields using script

I need to combine two text nested fields to a new field using scripts.

POST script/_update_by_query
{
  "script": {
    "source": """
      ctx._source.example = ctx._source.field1 + '_' + ctx._source.field2
    """,
    "lang": "painless"
  }
}

I used the above script to combine two fields, but the same is not able to do for nested fields
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx._source.last1 = ctx.source.log.match.id + '' + ctx._source.resourceId\n ",
" ^---- HERE"
],
"script" : "\n ctx._source.last1 = ctx.source.log.match.id + '' + ctx._source.resourceId\n ",
"lang" : "painless",
"position" : {
"offset" : 48,
"start" : 7,
"end" : 87
}
}
],
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx._source.last1 = ctx.source.log.match.id + '' + ctx._source.resourceId\n ",
" ^---- HERE"
],
"script" : "\n ctx._source.last1 = ctx.source.log.match.id + '' + ctx._source.resourceId\n ",
"lang" : "painless",
"position" : {
"offset" : 48,
"start" : 7,
"end" : 87
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Illegal list shortcut value [id]."
}
},
"status" : 400
}

Getting this error.

{
  "_index": "script",
  "_type": "_doc",
  "_id": "bbda6005174a13e4b457ebf9ce064cf0",
  "_score": 1,
  "_source": {
    "app": "ADC",
    "field2": "KU1T7GAGIS",
    "example": "XGHCWMNXA4_KU1T7GAGIS",
    "log": {
      "match": [
        {
          "zone": "val",
          "id": "999001020"
        }
      ]
    },
    "field1": "XGHCWMNXA4"
  }
}

This is my document

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