Setting a default value for missing fields during indexing or reindexing

I am trying to create an elastic search mapping where during indexing of data if a field is missing it should add some default value.

PUT my_index

{
  "mappings": {
    "_doc": {
      "properties": {
        "status_code": {
          "type": "keyword"
        },
        "response": {
          "type": "string"
        }
      }
    }
  }
}

PUT my_index/doc/1

{ "statuscode": "200" }

So, as in the above example response field is missing , is it possible to add some default value during indexing for response.?

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