an__snatcher
an__snatcher

Reputation: 131

How to Update the Field value with the default value for Whole Index in Elastic Search

I am using ES 6.x. I created a field 'abc' and currently I have 10 records in my Index. I want to update a value '1' to all the records at single time. What will be the preferred approach.

Upvotes: 0

Views: 456

Answers (1)

briarheart
briarheart

Reputation: 2006

You can use Update by Query API. Here is the example:

POST my_index/my_type/_update_by_query
{
  "script": {
    "source": "ctx._source.my_field = '1'",
    "lang": "painless"
  }
}

Upvotes: 1

Related Questions