如何使用追加第一个字符串UPDATE BY查询ElasticSearch

rnmwe5a2  于 2022-09-20  发布在  ElasticSearch
关注(0)|答案(1)|浏览(155)

我有个医生:

{
  "_index" : "name_index",
  "_type" : "_doc",
  "_id" : "45db3736bcccb55f28b9162b20d0c3",
  "_score" : 1.0,
  "_source" : {
    "path" : {
      "virtual" : "/2014/01/01/filename.pdf"
    }
  }
}

如何将字符串附加到第一个路径。虚拟:“虚拟”:“Uploads/2014/01/01/filename.pdf”

1szpjjfi

1szpjjfi1#

如果要更新索引所有文档(或其子集),可以使用_update_by_queryingest pipeline来完成。首先,定义您的摄取管道:

PUT _ingest/pipeline/modify-path
{
  "processors": [
    {
      "set": {
        "field": "path.virtual",
        "value": "Uploads{{{path.virtual}}}"
      }
    }
  ]
}

然后对您的索引运行它,如下所示:

POST name_index/_update_by_query?pipeline=modify-path
{
     "query": {
          "match_all": {}
     }
}

如果您只想对该文档执行此操作,则可以使用如下normal update

POST name_index/_doc/45db3736bcccb55f28b9162b20d0c3/_update
{
  "doc": {
    "path": {
       "virtual": "Uploads/2014/01/01/filename.pdf"
    }
  }
}

相关问题