Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Postman - Fatal编程技术网 elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值,elasticsearch,postman,elasticsearch,Postman" /> elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值,elasticsearch,postman,elasticsearch,Postman" />

elasticsearch 脚本参数不';t在ElasticSearch v7.3更新脚本中支持类型为:START_数组的值

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"

我正在尝试更新我的索引文档,通过Postman在更新API脚本时出现以下错误

{
    "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我已经更新了脚本。提前谢谢你的帮助