elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值
我正在尝试更新我的索引文档,通过Postman在更新API脚本时出现以下错误elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值,elasticsearch,postman,elasticsearch,Postman,我正在尝试更新我的索引文档,通过Postman在更新API脚本时出现以下错误 { "error": { "root_cause": [ { "type": "x_content_parse_exception", "reason": "[5:15] [script] params doesn't support values of type: START_ARRAY"
{
"error": {
"root_cause": [
{
"type": "x_content_parse_exception",
"reason": "[5:15] [script] params doesn't support values of type: START_ARRAY"
}
],
"type": "x_content_parse_exception",
"reason": "[5:15] [UpdateRequest] failed to parse field [script]",
"caused_by": {
"type": "x_content_parse_exception",
"reason": "[5:15] [script] params doesn't support values of type: START_ARRAY"
}
},
"status": 400
}
因为错误清楚地表明我正在更新文档中包含数据数组的字段。这是一个样本
"hasParts": [
{
"documentLevel": 2,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
}
]
我想使用其中一个文档的更新API更新上述属性
这可能吗?如果可能的话,我做错了什么?
提前谢谢你的帮助
编辑:
这是剧本
{
"script": {
"source": "ctx._source.hasParts.add(params.haspart)",
"lang": "painless",
"params": [
{
"haspart": [
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
}
]
}
]
}
}
您的
params
部分不能是数组,而是对象,请使用以下脚本:
{
"script": {
"source": "ctx._source.hasParts.add(params.haspart)",
"lang": "painless",
"params": {
"haspart": [
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
},
{
"documentLevel": 3,
"levelProperties": {
//some properties
}
}
]
}
}
}
添加所需的脚本trying@jaspreetchahal我已经更新了脚本。提前谢谢你的帮助