elasticsearch _update_by_query 不工作

elasticsearch _update_by_query doesn't work

弹性搜索:2.3.3

以下是我的命令顺序

索引文档

POST test-index/doc
{
  "name":"sahas"
}

检索文档

GET test-index/_search
{
  "query": {
    "match": {
      "name": "sahas"
    }
  }
}

更新文档

POST test-index/doc/_update_by_query?name=subramanian
{
  "query": {
    "match": {
      "name": "sahas"
    }
  }
}

更新结果

{
  "took": 9,
  "timed_out": false,
  "total": 1,
  "updated": 1,
  "batches": 1,
  "version_conflicts": 0,
  "noops": 0,
  "retries": 0,
  "failures": []
}

但是当我再次查询文档时,它没有更新。 无论如何要弄清楚为什么更新在这里不起作用? 我错过了什么傻事吗?

感谢任何意见..

您的查询更新没有修改源。为此,您需要包含一个脚本:

POST test-index/doc/_update_by_query
{
  "query": {
    "match": {
      "name": "sahas"
    }
  },
  "script": {
    "inline": "ctx._source.name = 'subramanian'"
  }
}