Updating a mapping in existing indicese

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)
I have also found this article on updating a mapping.
(Update mapping API | Elasticsearch Guide [7.16] | Elastic)
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.

I found this and appears to work:

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

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

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

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

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

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.

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