Elasticsearch 中的条件更新:"Invalid op [none]"
Conditional update in Elasticsearch: "Invalid op [none]"
弹性搜索 2.3。我正在触发此查询以根据条件更新索引中的每个文档。
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
]
}
},
"script": {
"inline": "if (ctx._source.url.endsWith('a=6')) ctx.op = 'none' else ctx._source.url = ctx._source.url + '&b=3'"
}
}
如 here 所述,我使用 ctx.op = 'none'
来避免更新不符合条件的文档。
我得到
Invalid op [none]
完整错误:
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Invalid op [none]"
}
],
"type": "illegal_argument_exception",
"reason": "Invalid op [none]"
},
"status": 400
好像很简单,看得我都懵了。感谢您的帮助。
正确的操作是noop
,不是none
。
Just as in Update API you can set ctx.op = "noop" if your script decides that it doesn’t have to make any changes. That will cause _update_by_query to omit that document from its updates.
弹性搜索 2.3。我正在触发此查询以根据条件更新索引中的每个文档。
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
]
}
},
"script": {
"inline": "if (ctx._source.url.endsWith('a=6')) ctx.op = 'none' else ctx._source.url = ctx._source.url + '&b=3'"
}
}
如 here 所述,我使用 ctx.op = 'none'
来避免更新不符合条件的文档。
我得到
Invalid op [none]
完整错误:
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Invalid op [none]"
}
],
"type": "illegal_argument_exception",
"reason": "Invalid op [none]"
},
"status": 400
好像很简单,看得我都懵了。感谢您的帮助。
正确的操作是noop
,不是none
。
Just as in Update API you can set ctx.op = "noop" if your script decides that it doesn’t have to make any changes. That will cause _update_by_query to omit that document from its updates.