elasticsearch - Elasticsearch中的条件更新: “Invalid op [none]”

标签 elasticsearch elasticsearch-2.0

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/

相关文章:

java - 如何根据字段值过滤 ElasticSearch 结果?

elasticsearch - 基巴纳 : Is there a way to get dashboards from command line?

elasticsearch - ElasticSearch的策展人可以使用 'atomic alias move'滚动索引吗?

elasticsearch - Elasticsearch分片重新分配

java - 将 Elasticsearch 的 DeleteByQueryPlugin 从 2.4 迁移到 5.2.2

elasticsearch - match_phrase查询的模糊行为

Elasticsearch 2.0 : _id is not configurable

java - 添加 `stdout` 后,LogStash JDBC 插件不会执行

elasticsearch - 三节点集群有多少master

python - 自定义 View 在带有 Elastic Search 的 Django Haystack 中不显示结果