# Using reindex to clean up a series of indexes (6.8.12)

**URL:** <https://discuss.elastic.co/t/using-reindex-to-clean-up-a-series-of-indexes-6-8-12/255917>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 19, 2020, 2:18am UTC](https://discuss.elastic.co/t/using-reindex-to-clean-up-a-series-of-indexes-6-8-12/255917 "2020-11-19T02:18:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [November 19, 2020, 2:18am UTC](https://discuss.elastic.co/t/using-reindex-to-clean-up-a-series-of-indexes-6-8-12/255917/1 "2020-11-19T02:18:57Z")

</div>

Background:

I am attempting to get a series of indexes into a consistent form -- the indexes span two years and over that time I have learnt a lot and there have been incremental improvements in the data quality.

The index now has a mapping specified and I don't want anything in the reindexed data that is not in the mapping.

There are also fields that have changed their names and I want to remap these and lastly there are IP addresses that now get geoip data added and I would like to do this for older entries too.

I see there is script option for reindex but the documentation is scant.

Specific questions:  
1/ is there a way to tell ES not to put any fields into a doc that is not in the index mapping?

2/ can I use "painless" scripts to clean up the data during the reindexing process? --if so an example of renaming a field, or reformatting a field would be appreciated.

3/ deleting specific fields from the index (not necessary if I can do this in the mapping)

---

<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:** [November 19, 2020, 2:27am UTC](https://discuss.elastic.co/t/using-reindex-to-clean-up-a-series-of-indexes-6-8-12/255917/2 "2020-11-19T02:27:54Z")

</div>

1. Use `dynamic: false` - [https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html)
2. Yeah you can, that's not my best area so hopefully someone else will jump in.
3. See 1.

---

<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:** [December 17, 2020, 2:27am UTC](https://discuss.elastic.co/t/using-reindex-to-clean-up-a-series-of-indexes-6-8-12/255917/3 "2020-12-17T02:27:58Z")

</div>

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