# Updating a mapping in existing indicese

**URL:** https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918
**Category:** Elasticsearch
**Created:** [January 20, 2022, 9:21am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918 "2022-01-20T09:21:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pruttle](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@pruttle](https://discuss.elastic.co/u/pruttle)
#### Post date: [January 20, 2022, 9:21am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/1 "2022-01-20T09:21:34Z")

</div>

Hi  
I have added a new mapping to an Index Template and it is updating new Indices as they are created. I need to update all the pre-existing retrospective Indices with the new mapping.  
What is the best approach to this?  
I have seen details of re-indexing  
([Reindex API | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html))  
I have also found this article on updating a mapping.  
([Update mapping API | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html))  
The latter looks less intensive and risky but will it achieve what I need?  
The mapping is an alias of an exiting mapping.  
Many thanks in advance.

---

<div class="post-metadata">

### Author: ![pruttle](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@pruttle](https://discuss.elastic.co/u/pruttle)
#### Post date: [January 20, 2022, 10:06am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/2 "2022-01-20T10:06:11Z")

</div>

Update:  
I found this and appears to work:

```auto
PUT /employee-*/_mapping
{
  "properties": {
    "SalaryPerYear" : {
          "type" : "long"
        }
  }
}

```

---

<div class="post-metadata">

### Author: ![pruttle](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@pruttle](https://discuss.elastic.co/u/pruttle)
#### Post date: [January 20, 2022, 10:09am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/3 "2022-01-20T10:09:29Z")

</div>

Further question: Is it possible to reverse this update and remove the mapping as easily?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 20, 2022, 10:22am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/4 "2022-01-20T10:22:06Z")

</div>

No. You can not change or remove mappings without reindexing.

---

<div class="post-metadata">

### Author: ![pruttle](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@pruttle](https://discuss.elastic.co/u/pruttle)
#### Post date: [January 20, 2022, 10:37am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/5 "2022-01-20T10:37:40Z")

</div>

Ok but the code above appears to update each doc and the index as required. Should I avoid this?

---

<div class="post-metadata">

### Author: ![pruttle](https://avatars.discourse-cdn.com/v4/letter/p/7ea924/32.png) [@pruttle](https://discuss.elastic.co/u/pruttle)
#### Post date: [January 20, 2022, 10:42am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/6 "2022-01-20T10:42:53Z")

</div>

To clarify. The code is just an example. The mapping I add is an alias to an existing mapping for time stamp.

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [January 20, 2022, 11:14am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/7 "2022-01-20T11:14:42Z")

</div>

Yes, the code works but only if the SalaryPerYear does not exist yet in the mappings.

You can update the mappings when you only add new fields (including alias field), but it is impossible to change existing fields mappings or delete existing fields.

---

<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: [February 17, 2022, 11:15am UTC](https://discuss.elastic.co/t/updating-a-mapping-in-existing-indicese/294918/8 "2022-02-17T11:15:20Z")

</div>

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