# Float and integer fields' datatypes

**URL:** https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025
**Category:** Elasticsearch
**Created:** [August 6, 2017, 9:26pm UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025 "2017-08-06T21:26:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![begemot](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@begemot](https://discuss.elastic.co/u/begemot)
#### Post date: [August 6, 2017, 9:26pm UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/1 "2017-08-06T21:26:17Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) and  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html) point that the following numeric data types are supported :

- long
- integer
- short
- byte
- double
- float
- half\_float
- scaled\_float

However this doc page, [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html), says:

Each field has a data type which can be:  
a simple type like text, keyword, date, long, double, boolean or ip.  
....

So does it mean fields cannot be integer and float and should be instead long and double accordingly ?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 7, 2017, 11:15am UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/2 "2017-08-07T11:15:11Z")

</div>

No, you can configure integers or floats or doubles or longs. The second listing was just an example. The first list is the definitive one.

---

<div class="post-metadata">

### Author: ![begemot](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@begemot](https://discuss.elastic.co/u/begemot)
#### Post date: [August 7, 2017, 9:59pm UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/3 "2017-08-07T21:59:24Z")

</div>

Hi Alexander ,  
Thanks  
How to use null\_value in mapping for all numeric and text type if we rely on dynamic mapping?  
Can you give an example?

---

<div class="post-metadata">

### Author: ![begemot](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@begemot](https://discuss.elastic.co/u/begemot)
#### Post date: [August 8, 2017, 5:55am UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/4 "2017-08-08T05:55:54Z")

</div>

When I place integer and float into dynamic template I got warning above acknowledgement in Kibana console:

#! Deprecation: match\_mapping\_type [integer] is invalid and will be ignored: No field type matched on [integer], possible values are [object, string, long, double, boolean, date, binary]  
#! Deprecation: match\_mapping\_type [float] is invalid and will be ignored: No field type matched on [float], possible values are [object, string, long, double, boolean, date, binary]

So I need to understand really if integer and float are supported and how to map them in dynamic template

---

<div class="post-metadata">

### Author: ![begemot](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@begemot](https://discuss.elastic.co/u/begemot)
#### Post date: [August 8, 2017, 9:53am UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/5 "2017-08-08T09:53:30Z")

</div>

I found in documentation a comment about match-mapping-type, see [https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type)

**The match\_mapping\_type matches on the datatype detected by dynamic field mapping, in other words, the datatype that Elasticsearch thinks the field should have. Only the following datatypes can be automatically detected: boolean, date, double, long, object, string**

Recommendation is to use "match\_mapping\_type": "long" for integer and "match\_mapping\_type": "double" for float data types.

I made correction to mapping. There is not more any Warning messages at index creation time. The mapping is created according to data type.  
However at runtime jave RestClient get Integer instance for long and integer datatype , and Double instance for float and doable datatype . The reason of that seems to me lays in Jackson2 object mapping. When Jackson2 needs to map float or long it does not distinguish the number received by RestClient in Response. The question is how serialized and deserialized Float and Long value using Jackson2 to aviid default Jackson behavior which coverts objects to Integer and Double

---

<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: [September 5, 2017, 9:53am UTC](https://discuss.elastic.co/t/float-and-integer-fields-datatypes/96025/6 "2017-09-05T09:53:35Z")

</div>

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