gpt4 book ai didi

elasticsearch - Elastic Search Groovy更新错误

转载 作者:行者123 更新时间:2023-12-03 01:56:36 25 4
gpt4 key购买 nike

我在Groovy脚本中遇到错误。

{"script":"if (ctx._source.containsKey(\"productoption\")) {ctx._source.productoption= [product];} else {ctx._source.productoption= [product];}","params":"{\"product\":[{\"id\":\"123ab\",\"name\":\"testing\"}]}"}

错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[ESMasterNode][127.0.0.1:9300][indices:data/write/update[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "failed to run inline script [if (ctx._source.containsKey(\"productoption\")) {ctx._source.productoption= [product];} else {ctx._source.productoption= [product];}] using lang [groovy]",
"caused_by": {
"type": "missing_property_exception",
"reason": "No such property: product for class: 3b2894bb604d8fb601b627ert64e3fde8242f1b2"
}
}
},
"status": 400
}

它以某种方式无法识别与此一起发送的参数。我有什么想念的吗?

最佳答案

传递params时,您犯了一个小错误。
像这样使用它,您可以开始:

{
"script":"if (ctx._source.containsKey(\"productoption\")) {ctx._source.productoption= [product];} else {ctx._source.productoption= [product];}",
"params": {
"product": [
{
"id": "123ab",
"name": "testing"
}
]
}
}

关于elasticsearch - Elastic Search Groovy更新错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36195388/

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