Elastcisearch copy two fields to the object for every document

First you need to hit the _update_by_query endpoint

Then, since test_field doesn’t exist in your document, you need to create it:

This should work for you:

POST test_index/_update_byquery
{
  "query":{
    "match":{
      "field1":1
    }
  },
  "script" : {
      "inline": "ctx._source.test_field = ['field1': ctx._source.field1, 'field2': ctx._source.field2]"
  }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top