# Change the data type mapping of a field

**URL:** <https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512>\
**Category:** Kibana\
**Created:** [February 26, 2018, 2:59pm UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512 "2018-02-26T14:59:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghouston10](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@ghouston10](https://discuss.elastic.co/u/ghouston10)\
**Post date:** [February 26, 2018, 2:59pm UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/1 "2018-02-26T14:59:39Z")

</div>

Hi,

I have a loaded index in Kibana. I need to perform a regex search on one of the fields. The field is currently type 'text' and the regex search doesn't seem to work correctly on 'text' fields. I have tested my regex searches on 'keyword' fields and they work perfectly. Therefore I am looking to change the field from 'text' to 'keyword' so I can perform regex searches on this field.

Is this possible and if so, how can it be achieved?

Thanks

---

<div class="post-metadata">

**Author:** ![Leandro\_Sampaio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandro_sampaio/32/18409_2.png) [@Leandro\_Sampaio](https://discuss.elastic.co/u/Leandro_Sampaio)\
**Post date:** [February 27, 2018, 3:07am UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/2 "2018-02-27T03:07:52Z")

</div>

Use this tip:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html)

POST /twitter/\_close

PUT /twitter/\_settings  
{  
"analysis" : {  
"analyzer":{  
"content":{  
"type":"custom",  
"tokenizer":"whitespace"  
}  
}  
}  
}

POST /twitter/\_open

Adapt to your case.

---

<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 27, 2018, 3:13am UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/3 "2018-02-27T03:13:05Z")

</div>

That won't work unfortunately. You will need to reindex with a mapping that matches what you want.

---

<div class="post-metadata">

**Author:** ![ghouston10](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@ghouston10](https://discuss.elastic.co/u/ghouston10)\
**Post date:** [February 27, 2018, 11:42am UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/4 "2018-02-27T11:42:14Z")

</div>

ok, so the only resolution is to create a new index with new mappings and input all the data again ?

---

<div class="post-metadata">

**Author:** ![ghouston10](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@ghouston10](https://discuss.elastic.co/u/ghouston10)\
**Post date:** [February 27, 2018, 12:44pm UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/5 "2018-02-27T12:44:22Z")

</div>

I did more research today and found the re index API which seems to achieve the task I want.

---

<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 27, 2018, 12:44pm UTC](https://discuss.elastic.co/t/change-the-data-type-mapping-of-a-field/121512/6 "2018-03-27T12:44:30Z")

</div>

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