# Convert string to int by reindexing

**URL:** <https://discuss.elastic.co/t/convert-string-to-int-by-reindexing/217456>\
**Category:** Elasticsearch\
**Created:** [January 31, 2020, 7:58pm UTC](https://discuss.elastic.co/t/convert-string-to-int-by-reindexing/217456 "2020-01-31T19:58:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joelxref](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@joelxref](https://discuss.elastic.co/u/joelxref)\
**Post date:** [January 31, 2020, 7:58pm UTC](https://discuss.elastic.co/t/convert-string-to-int-by-reindexing/217456/1 "2020-01-31T19:58:08Z")

</div>

I have quite a few indexes matching the pattern logstash-\*

In them I have a keyword called 'bytes\_read'.

It's type according to elasticsearch is string. This is due to an issue with our logstash configuration. I have corrected this configuration.

1. Is it possible to add a field to all existing index called \_bytes\_read that's in integer form?
2. Is this achievable via the reindexing API?
3. Is there a better way?

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loren/32/44942_2.png) [@loren](https://discuss.elastic.co/u/loren)\
**Post date:** [January 31, 2020, 8:56pm UTC](https://discuss.elastic.co/t/convert-string-to-int-by-reindexing/217456/2 "2020-01-31T20:56:49Z")

</div>

You can certainly [add a new field](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html#indices-put-mapping) to the existing mapping. For it to be populated with an int version of your keyword, you'll then need to run an Update-by-Query to [pick up the new property](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html#picking-up-a-new-property).

You could also [change the mapping of the existing field](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html#updating-field-mappings) via reindexing and aliasing the index.

---

<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:** [February 28, 2020, 8:56pm UTC](https://discuss.elastic.co/t/convert-string-to-int-by-reindexing/217456/3 "2020-02-28T20:56:55Z")

</div>

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