文档内容如下:
PUT /parts/_doc/1
{
"test-parts" : [],
"mint" : 1
}
更新脚本如下:
POST parts/_update/1
{
"script": {
"source": "ctx._source.test-parts.add(params.part)",
"lang": "painless",
"params": {
"part": {"1" : "abhuj"}
}
}
}
执行报错:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "failed to execute script"
}
],
"type" : "illegal_argument_exception",
"reason" : "failed to execute script",
"caused_by" : {
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"ctx._source.test-parts.add(params.part)",
" ^---- HERE"
],
"script" : "ctx._source.test-parts.add(params.part)",
"lang" : "painless",
"position" : {
"offset" : 17,
"start" : 0,
"end" : 39
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Variable [parts] is not defined."
}
}
},
"status" : 400
}
将文档字段中“-”去掉或修改,可正常完成。
新人求教,希望得到解答。
PUT /parts/_doc/1
{
"test-parts" : [],
"mint" : 1
}
更新脚本如下:
POST parts/_update/1
{
"script": {
"source": "ctx._source.test-parts.add(params.part)",
"lang": "painless",
"params": {
"part": {"1" : "abhuj"}
}
}
}
执行报错:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "failed to execute script"
}
],
"type" : "illegal_argument_exception",
"reason" : "failed to execute script",
"caused_by" : {
"type" : "script_exception",
"reason" : "compile error",
"script_stack" : [
"ctx._source.test-parts.add(params.part)",
" ^---- HERE"
],
"script" : "ctx._source.test-parts.add(params.part)",
"lang" : "painless",
"position" : {
"offset" : 17,
"start" : 0,
"end" : 39
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Variable [parts] is not defined."
}
}
},
"status" : 400
}
将文档字段中“-”去掉或修改,可正常完成。
新人求教,希望得到解答。
1 个回复
pony_maggie - 公众号:犀牛饲养员的技术笔记
赞同来自:
你可以考虑使用下划线