I have an index to which i need to add a field which will merge three existing fields from the same index. Example field1, field2, field3 so unique_field=field1,field2,field3.
I am trying below script along with reindexing which gives me error.
POST _reindex
{
"source":{
"index" : "old"
},
"dest": {
"index": "new"
},
"script": {
"inline": "ctx._source.unique_field=ctx_source.field1+ ',' + ctx._source.field2+ ',' + ctx._source.field3",
"lang": "painless"
}
}
Throws error like -> "error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... tx._source.unique_field=ctx_source.field1+ ...",
" ^---- HERE"
],
"script": "ctx._source.unique_field=ctx_source.field1+ ',' + ctx._source.field2+ ',' + ctx._source.field3",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "compile error",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [ctx_source] is not defined."
},
"script_stack": [
"... tx._source.unique_field=ctx_source.application + ...",
" ^---- HERE"
],
"script": "ctx._source.unique_action=ctx_source.application + ',' + ctx._source.subsystem + ',' + ctx._source.action",
"lang": "painless"
},
"status": 500