# Lower casing all field names in reindex

**URL:** <https://discuss.elastic.co/t/lower-casing-all-field-names-in-reindex/84842>\
**Category:** Elasticsearch\
**Created:** [May 7, 2017, 10:16am UTC](https://discuss.elastic.co/t/lower-casing-all-field-names-in-reindex/84842 "2017-05-07T10:16:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrolsen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lrolsen/32/5953_2.png) [@lrolsen](https://discuss.elastic.co/u/lrolsen)\
**Post date:** [May 7, 2017, 10:16am UTC](https://discuss.elastic.co/t/lower-casing-all-field-names-in-reindex/84842/1 "2017-05-07T10:16:00Z")

</div>

Hi,

I have an existing index where there are a lot of 'duplicate' field names due to case sensitivity. I would like to reindex this index so it contains only lower case field names.

Judging from the examples it should be possible using the reindex api and painless:

"ctx.\_source.tag = ctx.\_source.remove("Tag")"

However, since my index contains 2000+ fields I would rather not have to hard-code the field names of each and every duplicate field.

Is there a more scalable way to do this so it just automatically lower cases every field in the index?

---

<div class="post-metadata">

**Author:** ![lwintergerst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lwintergerst/32/18164_2.png) [@lwintergerst](https://discuss.elastic.co/u/lwintergerst)\
**Post date:** [May 9, 2017, 2:53pm UTC](https://discuss.elastic.co/t/lower-casing-all-field-names-in-reindex/84842/2 "2017-05-09T14:53:37Z")

</div>

Hi Lars,  
I don't have time to type up the correct script right now, but you should be able to do this using HashSets.  
Take the content of the source, put it in a set, lowercase the keys and replace the existing source with it.

Sorry that I can't be of more help right now.

Luca

---

<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:** [June 6, 2017, 3:02pm UTC](https://discuss.elastic.co/t/lower-casing-all-field-names-in-reindex/84842/3 "2017-06-06T15:02:01Z")

</div>

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