# Is it possible to update a mapping field by only reindexing documents affected by the change?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222
**Category:** Elasticsearch
**Created:** [February 15, 2017, 3:53pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222 "2017-02-15T15:53:45Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)
#### Post date: [February 15, 2017, 3:53pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/1 "2017-02-15T15:53:45Z")

</div>

I did something dumb and deployed a service that populates a new field in our Elasticsearch index before applying the corresponding mapping to the index. As a result, about 40 documents were indexed with the default string analyzer instead of `not_analyzed`. I understand the reasoning for not allowing mapping types to be changed:

> If a mapping already exists for a field, data from that field has probably been indexed. If you were to change the field mapping, the indexed data would be wrong and would not be properly searchable.

What I'm wondering is if I can just reindex the offending 40 documents, or even just delete the index for the field, so that the issue of corrupted data from that field no longer matters. This is a production index with almost 300k documents, so reindexing the entire thing and causing a temporary outage would be inconvenient.

---

<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: [February 15, 2017, 10:10pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/2 "2017-02-15T22:10:22Z")

</div>

How did you fix that for the other docs?  
(ES doesn't allow conflicting mappings)

---

<div class="post-metadata">

### Author: ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)
#### Post date: [February 15, 2017, 10:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/3 "2017-02-15T22:16:33Z")

</div>

I never "fixed" them, they just never had the field to begin with. I would also be fine with deleting the field in the problem docs, but I'm not sure if that would solve my problem either.

---

<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: [February 15, 2017, 10:50pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/4 "2017-02-15T22:50:29Z")

</div>

You can't delete fields, you need to reindex which you can do into the same index, then just delete those bad docs.

---

<div class="post-metadata">

### Author: ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)
#### Post date: [February 16, 2017, 3:22pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/5 "2017-02-16T15:22:44Z")

</div>

> reindex which you can do into the same index

What do you mean by this?

Basically what I was hoping was that if I delete any references to that field, that Elasticsearch would let me delete the mapping since the index for that field would be empty. But it sounds like that isn't possible.

I wouldn't mind if searching on that field doesn't work for the 40 that were accidentally indexed, if docs going forward were indexed correctly.

---

<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: [February 16, 2017, 9:43pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/6 "2017-02-16T21:43:46Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-reindex.html) is what I mean.

---

<div class="post-metadata">

### Author: ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)
#### Post date: [February 16, 2017, 9:49pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/7 "2017-02-16T21:49:28Z")

</div>

Ah, I see. Unfortunately we don't have access to that endpoint since we're using the AWS Elasticsearch Service.

---

<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: [March 16, 2017, 9:49pm UTC](https://discuss.elastic.co/t/is-it-possible-to-update-a-mapping-field-by-only-reindexing-documents-affected-by-the-change/75222/8 "2017-03-16T21:49:31Z")

</div>

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