gpt4 book ai didi

elasticsearch - 脚本参数不支持 : START_ARRAY in ElasticSearch v7. 类型的值 3 更新脚本

转载 作者:行者123 更新时间:2023-12-02 22:16:26 27 4
gpt4 key购买 nike

我正在尝试为我的索引更新文档,并在通过 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
}
}
]
}
}
}

关于elasticsearch - 脚本参数不支持 : START_ARRAY in ElasticSearch v7. 类型的值 3 更新脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58097471/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com