Default values for missing fields

I think that the only way to do something like that is using an ingest pipeline with some processors that would add the field if it does not exist.

It is not the cleanest way as it depends on the number of fields you want to add, but it works. You could create an ingest pipeline, configure your template to use this pipeline as the index.final_pipeline and then add some set processors with conditionals to check if the field exists.

An example of a set processor would be this:

    {
      "set": {
        "field": "age",
        "value": 0,
        "override": false,
        "if": "ctx.age == null",
        "ignore_failure": true
      }
    }
1 Like