In Elasticsearch 7.15.0, I am unable to emit a list of strings for a keyword runtime field:
PUT warning
PUT warning/_mapping
{
"dynamic": false,
"runtime": {
"Warning": {
"type": "keyword",
"script": {
"source": "emit(['Warning 1']);"
}
}
}
}
==>
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"emit(['Warning 1']);",
" ^---- HERE"
],
"script" : "emit(['Warning 1']);",
"lang" : "painless",
"position" : {
"offset" : 5,
"start" : 0,
"end" : 20
}
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: compile error",
"caused_by" : {
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"emit(['Warning 1']);",
" ^---- HERE"
],
"script" : "emit(['Warning 1']);",
"lang" : "painless",
"position" : {
"offset" : 5,
"start" : 0,
"end" : 20
},
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "Cannot cast from [java.util.ArrayList] to [java.lang.String]."
}
}
},
"status" : 400
}
Is this the expected behavior or am I doing something wrong?