# Update by query after mapping change

**URL:** https://discuss.elastic.co/t/update-by-query-after-mapping-change/276397
**Category:** Elasticsearch
**Created:** [June 18, 2021, 2:27pm UTC](https://discuss.elastic.co/t/update-by-query-after-mapping-change/276397 "2021-06-18T14:27:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![YvorL](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@YvorL](https://discuss.elastic.co/u/YvorL)
#### Post date: [June 18, 2021, 2:27pm UTC](https://discuss.elastic.co/t/update-by-query-after-mapping-change/276397/1 "2021-06-18T14:27:43Z")

</div>

Hi,

In case I have a daily index and want to add a new field without waiting for the new index that would re-read the mapping template, I can use the [Update mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html). What I'm not 100% sure is that I would only need to use [Update By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) when I have documents that I want to update with the new field. To put this another way:  
If I don't want to update indexed documents in the target index, only have the newly indexed ones picking up the mapping change (new field), I don't need to run an update, right?

Thanks!

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 21, 2021, 8:57am UTC](https://discuss.elastic.co/t/update-by-query-after-mapping-change/276397/2 "2021-06-21T08:57:05Z")

</div>

Correct! When you add a new field via update mapping API, this will be only applied for newly indexed documents, old documents won't be affected in any way.

---

<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: [July 19, 2021, 8:57am UTC](https://discuss.elastic.co/t/update-by-query-after-mapping-change/276397/3 "2021-07-19T08:57:28Z")

</div>

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