# Cannot get the correct field's type on kibana

**URL:** <https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194>\
**Category:** Kibana\
**Created:** [November 2, 2017, 12:34pm UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194 "2017-11-02T12:34:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adansar](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@Adansar](https://discuss.elastic.co/u/Adansar)\
**Post date:** [November 2, 2017, 12:34pm UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/1 "2017-11-02T12:34:26Z")

</div>

Hi everyone,

I have a problem on Kibana, I converted a field from string to integer on the logstash configuration file using mutate { convert ..  
....  
if [exportedRecords]{  
mutate{  
convert =\> { "exportedRecords" =\> "integer" }  
}  
....

But when i get the field on kibana, i get it as a string.

What should i do ?

Best Regards.

---

<div class="post-metadata">

**Author:** ![Oozza](https://avatars.discourse-cdn.com/v4/letter/o/76d3ee/32.png) [@Oozza](https://discuss.elastic.co/u/Oozza)\
**Post date:** [November 3, 2017, 8:36am UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/2 "2017-11-03T08:36:40Z")

</div>

Hi,  
The type of field is configured in Elasticsearch.

If you didn't specify mapping for your index a default dynamic mapping probably set the field type to text. Once something is written into the index the mapping won't change.

You should create a template for the logstash index and specify a mapping. Then recreate the index.

Just recreating the index can also help. If the first item you write to index to the field is a number, the mapping may be automatically set to number, but this is not the correct way.

---

<div class="post-metadata">

**Author:** ![Adansar](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@Adansar](https://discuss.elastic.co/u/Adansar)\
**Post date:** [November 3, 2017, 8:44am UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/3 "2017-11-03T08:44:30Z")

</div>

If i recreate the index, is there any risk to lose the data i already have on it ? and how could i create a template for the logstash index please?

Thank you.

---

<div class="post-metadata">

**Author:** ![Oozza](https://avatars.discourse-cdn.com/v4/letter/o/76d3ee/32.png) [@Oozza](https://discuss.elastic.co/u/Oozza)\
**Post date:** [November 3, 2017, 9:39am UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/4 "2017-11-03T09:39:27Z")

</div>

A field type for old data can be changed but it will require reindexing ([Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)). There is also a nice blog about changing mapping [https://www.elastic.co/blog/changing-mapping-with-zero-downtime](https://www.elastic.co/blog/changing-mapping-with-zero-downtime).

If you never heard about mapping and templates, it would be good to google a bit and eventually come with more specific questions and your use case.

---

<div class="post-metadata">

**Author:** ![Adansar](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@Adansar](https://discuss.elastic.co/u/Adansar)\
**Post date:** [November 3, 2017, 4:48pm UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/5 "2017-11-03T16:48:37Z")

</div>

thank you

---

<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 1, 2017, 4:48pm UTC](https://discuss.elastic.co/t/cannot-get-the-correct-fields-type-on-kibana/106194/6 "2017-12-01T16:48:42Z")

</div>

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