# Update mappings without having to delete indexes

**URL:** <https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870>\
**Category:** Elasticsearch\
**Created:** [July 20, 2020, 9:40am UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870 "2020-07-20T09:40:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![g30](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@g30](https://discuss.elastic.co/u/g30)\
**Post date:** [July 20, 2020, 9:40am UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870/1 "2020-07-20T09:40:53Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 20, 2020, 11:44pm UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870/2 "2020-07-20T23:44:22Z")

</div>

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.

> [@g30](#):
>
> 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?

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

---

<div class="post-metadata">

**Author:** ![g30](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@g30](https://discuss.elastic.co/u/g30)\
**Post date:** [July 21, 2020, 9:09am UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870/3 "2020-07-21T09:09:09Z")

</div>

> 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](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 21, 2020, 11:27pm UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870/4 "2020-07-21T23:27:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 18, 2020, 11:27pm UTC](https://discuss.elastic.co/t/update-mappings-without-having-to-delete-indexes/241870/5 "2020-08-18T23:27:33Z")

</div>

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