Reindex with new boolean field and null_value

Hi,

I was adding a new boolean field for an existing index and need to have that field for all existing documents with the default value of false. So I changed the template for my indexes and added a mapping like this:

    "user.login.blocked": {
       "type": "boolean",
       "null_value": false
    }

Then I re indexed it to users-2017.04.12-2, deleted the old index and re indexed it back to users-2017.04.12 and took a look into it.

While it works for all new documents, the old one still have no blocked field. Isn't the null_value supposed to fill in false for every document that does not have this field filled or is there any other way to accomplish this?

null_value is a mapping concept and mappings never change the _source. I'd have added the new field and then used _update_by_query and a script to set the value to whatever you wanted.

Also, .s in field names are pretty painful. I'd avoid them and use actual object fields instead. The tricks required to get them to play nice with object resolution make me want to stay away from them.

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