Find and replace in elasticsearch all documents

前端 未结 1 463
遇见更好的自我
遇见更好的自我 2020-12-20 06:30

I wanted to replace the single username in all my elasticsearch index documents. Is there any API query ?

I tried searching multiple but couldn\'t find. Any one has

1条回答
  •  生来不讨喜
    2020-12-20 07:02

    update-by-query is the way to go.

    POST /test/movies/_update_by_query
    {
      "script": {
        "inline": "ctx._source.user = 'alice'"
      },
      "query": {
        "term": {
          "user": "bob"
        }
      }
    }
    

    Note: make sure to enable dynamic scripting in order for this to work.

    0 讨论(0)
提交回复
热议问题