Hi to everyone!
Few days ago someone in my company has created in my cluster a field called total_chunks.RS|24|12:24
and I would like to rename It with an update_by_query
.
I have tried this query:
{
"query": {
"bool": {
"must": {
"exists": {
"field": "body.total_chunks.RS|24|12:24"
}
}
}
},
"script" : {
"inline": """ ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12:24; \n ctx._source.remove(\"body.total_chunks.RS|24|12:24\");"""
}
}
And returns to me this error:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"... ody.total_chunks.RS|24|12:24; \\n ctx._source.remov ...",
" ^---- HERE"
],
"script" : " ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12:24; \\n ctx._source.remove(\\\"body.total_chunks.RS|24|12:24\\\");",
"lang" : "painless",
"position" : {
"offset" : 83,
"start" : 58,
"end" : 108
}
}
],
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"... ody.total_chunks.RS|24|12:24; \\n ctx._source.remov ...",
" ^---- HERE"
],
"script" : " ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12:24; \\n ctx._source.remove(\\\"body.total_chunks.RS|24|12:24\\\");",
"lang" : "painless",
"position" : {
"offset" : 83,
"start" : 58,
"end" : 108
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "unexpected token [':'] was expecting one of [{<EOF>, ';'}]."
}
},
"status" : 400
}
So I thought to escape colon, but if I insert a backslash, another error occurs:
This is the inline script with the escaped colon
""" ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12\:24; \n ctx._source.remove(\"body.total_chunks.RS|24|12:24\");"""
And this is the new error, that says that backslash was unexpected:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"... ody.total_chunks.RS|24|12\\:24; \\n ctx._source.remo ...",
" ^---- HERE"
],
"script" : " ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12\\:24; \\n ctx._source.remove(\\\"body.total_chunks.RS|24|12:24\\\");",
"lang" : "painless",
"position" : {
"offset" : 83,
"start" : 58,
"end" : 108
}
}
],
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"... ody.total_chunks.RS|24|12\\:24; \\n ctx._source.remo ...",
" ^---- HERE"
],
"script" : " ctx._source.body.total_chunks.RS_24_12_24 = ctx._source.body.total_chunks.RS|24|12\\:24; \\n ctx._source.remove(\\\"body.total_chunks.RS|24|12:24\\\");",
"lang" : "painless",
"position" : {
"offset" : 83,
"start" : 58,
"end" : 108
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "unexpected character [\\].",
"caused_by" : {
"type" : "lexer_no_viable_alt_exception",
"reason" : null
}
}
},
"status" : 400
}
What I'm doing wrong here?
Thank you in advance