Add new field to existing documents in an index


I need to add a new field to all the docs present in the index. Is there a way to accomplish this ?

if all you have to do is to add a new field, you can accomplish it with an update_by_query (see documentation) and a simple script. Something like

POST your_index/_update_by_query
  "script": {
    "source": "ctx._source.new_field = null"

Of course, feel free to choose any other null value.

yes it worked .....

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.