# ElasticSearch saving integer field as String

**URL:** https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920
**Category:** Elasticsearch
**Created:** [November 24, 2014, 6:39pm UTC](https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920 "2014-11-24T18:39:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Rashmi\_Gogia](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@Rashmi\_Gogia](https://discuss.elastic.co/u/Rashmi_Gogia)
#### Post date: [November 24, 2014, 6:39pm UTC](https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920/1 "2014-11-24T18:39:51Z")

</div>

Hi,

Could some one help me figure out what is the issue with below Logstash  
Configuration /mapping template . ES seems to ignore the mappings specified  
in the template and stores everything as string.

I am using Logstash csv plugin to create index. My logstash conf file has  
csv filter as below:

filter {  
csv {  
columns =\> ["ESpeedRef","ProcessName",TotalMilliSec,AnyFloatNumber]  
separator =\> ","  
}

output {  
elasticsearch{  
protocol =\> "http"  
host =\> "localhost"  
index =\> "test\_index"  
}  
}

Below json template is used to define field mappings. I use curl to send  
template to ES.

{"template": "test\_index",  
"settings": {  
"number\_of\_shards": 1  
},  
"mappings": {  
"user": {  
"properties": {  
"ESpeedRef": {"type" : "string"},  
"ProcessName": {"type" : "string"},  
"TotalMilliSec": {"type" : "integer"},  
"AnyFloatNumber": {"type" : "float"}  
}  
}  
}  
}

When creating index, Elastic Search does apply this template. I can confirm  
this my looking at below console stmts:

[2014-11-24 13:22:51,099][INFO][cluster.metadata] [Captain  
America] [  
test\_index] creating index, cause [auto(bulk api)], shards [1]/[1], mappings  
[user]  
[2014-11-24 13:22:51,146][INFO][cluster.metadata] [Captain  
America] [  
test\_index] update\_mapping [logs] (dynamic)

In Kibana i see the fields TotalMilliSec and AnyFloatNumber are saved as  
string.. why??

Thanks  
Rashmi

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/568cb316-5946-4fbc-ad87-f65a413b990d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/568cb316-5946-4fbc-ad87-f65a413b990d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![sumit\_gupta\_sgt](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sumit\_gupta\_sgt](https://discuss.elastic.co/u/sumit_gupta_sgt)
#### Post date: [November 27, 2014, 6:51am UTC](https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920/2 "2014-11-27T06:51:18Z")

</div>

Hi,

You can define mapping in ES Template.

Thanks,  
Sumit

---

<div class="post-metadata">

### Author: ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)
#### Post date: [December 6, 2014, 1:33pm UTC](https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920/3 "2014-12-06T13:33:44Z")

</div>

Hi Rashmi,

Do not you set “type” in Logstash configuration?

If you don’t set, logstash use “logs” for “index\_type” in output elasticsearch.  
See : [https://github.com/elasticsearch/logstash/blob/1.4/lib/logstash/outputs/elasticsearch.rb#L300](https://github.com/elasticsearch/logstash/blob/1.4/lib/logstash/outputs/elasticsearch.rb#L300)

Then you should change “logs” instead of “user” in your mappings in template.

* * *

Jun Ohtani  
[johtani@gmail.com](mailto:johtani@gmail.com)  
blog : [http://blog.johtani.info](http://blog.johtani.info)  
twitter : [http://twitter.com/johtani](http://twitter.com/johtani)

> 2014/11/25 3:39、Rashmi Gogia [gogia.rashmi@gmail.com](mailto:gogia.rashmi@gmail.com) のメール：
> 
> Hi,
> 
> Could some one help me figure out what is the issue with below Logstash Configuration /mapping template . ES seems to ignore the mappings specified in the template and stores everything as string.
> 
> I am using Logstash csv plugin to create index. My logstash conf file has csv filter as below:
> 
> filter {  
> csv {  
> columns =\> ["ESpeedRef","ProcessName",TotalMilliSec,AnyFloatNumber]  
> separator =\> ","  
> }
> 
> output {  
> elasticsearch{  
> protocol =\> "http"  
> host =\> "localhost"  
> index =\> "test\_index"  
> }  
> }
> 
> Below json template is used to define field mappings. I use curl to send template to ES.
> 
> {"template": "test\_index",  
> "settings": {  
> "number\_of\_shards": 1  
> },  
> "mappings": {  
> "user": {  
> "properties": {  
> "ESpeedRef": {"type" : "string"},  
> "ProcessName": {"type" : "string"},  
> "TotalMilliSec": {"type" : "integer"},  
> "AnyFloatNumber": {"type" : "float"}  
> }  
> }  
> }  
> }
> 
> When creating index, Elastic Search does apply this template. I can confirm this my looking at below console stmts:
> 
> [2014-11-24 13:22:51,099][INFO][cluster.metadata] [Captain America] [  
> test\_index] creating index, cause [auto(bulk api)], shards [1]/[1], mappings  
> [user]  
> [2014-11-24 13:22:51,146][INFO][cluster.metadata] [Captain America] [  
> test\_index] update\_mapping [logs] (dynamic)
> 
> In Kibana i see the fields TotalMilliSec and AnyFloatNumber are saved as string.. why??
> 
> Thanks  
> Rashmi
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/568cb316-5946-4fbc-ad87-f65a413b990d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/568cb316-5946-4fbc-ad87-f65a413b990d%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/EE908F38-2DED-4624-A4CD-2E3DC9774C65%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/EE908F38-2DED-4624-A4CD-2E3DC9774C65%40gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 12:45am UTC](https://discuss.elastic.co/t/elasticsearch-saving-integer-field-as-string/20920/4 "2017-07-06T00:45:20Z")

</div>


