I have an index that for one reason or another we've added fields to that don't exist in our mapping. For example:
{
"name": "Bob" // Exists in mapping
"age": 12 // doesn't existing in mapping
}
After updating the mapping to add the age
field, any document we add the age
field to is queryable, but none of the documents that had age
added before we updated the mapping are queryable.
Is there a way to tell Elastic to make those older documents queryable, not just any net-new/updated after the mapping update?
CodePudding user response:
This implies that you must have dynamic: false
in your mapping, i.e. whenever you send a new field, you prevent ES from creating it automatically.
Once you have updated your mapping, you can then simply call _update_by_query
on your index in order to update it and have it reindex the data it contains with the new mappings.
Your queries will then work also on the "older" data.