Update mappings without having to delete indexes

Hi,

We are using elastic search for a file storage api implementation where by files are stored with metadata and the metadata is stored to elastic search. We are having issues at the moment where by when we need to add a new field to the existing mappings for an index our only option is to

  • Delete the index
  • Push the new mappings
  • Store data again

This is fine for test environments but it's not an option for production especially where we have hundreds of thousands of documents stored.

What is the best option / approach for this? I was potentially looking into reindexing old_index to new_index but do we need to update all the old data with the new fields first?

EDIT: update so I found https://www.elastic.co/blog/changing-mapping-with-zero-downtime

Still unclear though even with the alias approach when I reindex the data from index_old -> index_new do I need the update the data while i'm doing it and add in the new fields?

Thanks

You don't need to delete the index to add a new field.
You may find that a reindex is the easiest way to add data to the new field for older indices.

Yes, otherwise the older data without the field will be empty.

Yes, otherwise the older data without the field will be empty.

But for updating the data with the new field this is a custom re-index process I need to run then? Not covered by Reindex API | Elasticsearch Guide [8.11] | Elastic

Elasticsearch doesn't know what you want to put in the field, so yes, you need to tell it.

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