# Dynamic rename a field name

**URL:** <https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573>\
**Category:** Elasticsearch\
**Created:** [May 10, 2019, 2:03pm UTC](https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573 "2019-05-10T14:03:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylin](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@ylin](https://discuss.elastic.co/u/ylin)\
**Post date:** [May 10, 2019, 2:03pm UTC](https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573/1 "2019-05-10T14:03:40Z")

</div>

We want to index lab results in Elasticsearch. Because result readouts can be numeric, string or date. And the readouts of different lab results can be dynamic. So in logstash, we prefix the readouts with either 'numberic\_' or 'string\_' so that we can define a dynamic template to match types to prefixes. However, we still like to use the original readout name when indexing the readouts. Is there a way to dynamic rename the readout names, i.e. to remove the prefix we added in logstash?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [May 11, 2019, 9:55pm UTC](https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573/2 "2019-05-11T21:55:27Z")

</div>

Take a look at the [reindex api](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html). You can use that in combination with a reindex script to remap fields into different fieldnames.

---

<div class="post-metadata">

**Author:** ![ylin](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@ylin](https://discuss.elastic.co/u/ylin)\
**Post date:** [May 13, 2019, 3:44pm UTC](https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573/3 "2019-05-13T15:44:43Z")

</div>

Thank you for your reply. Because we can have new lab result type with new readout (properties) quite often. That is the reason we use dynamic template. Using reindex, we may have to reindex whenever a new type of lab result is indexed, and may have to be manual.

---

<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 10, 2019, 3:44pm UTC](https://discuss.elastic.co/t/dynamic-rename-a-field-name/180573/4 "2019-06-10T15:44:48Z")

</div>

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