Elasticsearch 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
。
从the documentation:
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.
公关创建:https://github.com/elastic/elasticsearch/pull/24613
关于elasticsearch - Elasticsearch中的条件更新: “Invalid op [none]”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43912087/