# Is this an error in documentation of "numeric\_detection"

**URL:** https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944
**Category:** Elasticsearch
**Created:** [December 17, 2020, 6:14am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944 "2020-12-17T06:14:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [December 17, 2020, 6:14am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/1 "2020-12-17T06:14:40Z")

</div>

Hi,  
I was going through the documentation of [Dynamic Field Mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html).

In the table I see the last entry:

**JSON data type**....................................... **Elasticsearch data type**  
string........................................................ Either a [`date`](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html) field (if the value passes [date detection](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html#date-detection)), a [`double`](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) or [`long`](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) field (if the value passes [numeric detection](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html#numeric-detection)) or a [`text`](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html) field, with a [`keyword`](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html) sub-field.

My understanding is that the default will be double or long.

However in the same page later on, the section on [Numeric Detection](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html#numeric-detection) has an example where it is said:

The `my_float` field is added as a [`float`](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) field.

It mapped it as a float instead of double.

---

<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: [December 21, 2020, 3:16am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/2 "2020-12-21T03:16:24Z")

</div>

> [@pk.241011](#):
>
> My understanding is that the default will be double or long.

It depends on what is detected.

> [@pk.241011](#):
>
> The `my_float` field is added as a [`float`](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) field.
> 
> It mapped it as a float instead of double.

Again, it depends on what is detected.

---

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [December 21, 2020, 4:18am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/3 "2020-12-21T04:18:36Z")

</div>

Hi Mark,

Here is what the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html) is saying on the numeric types:  
long -\> A signed 64-bit **integer**  
double -\> A double-precision 64-bit IEEE 754 **floating** point number  
float -\> A single-precision 32-bit IEEE 754 floating point number

And it is here I am getting confused. It should have detected it as a long or double. But it detected it as **float**.

Should the documentation for Dynamic field mapping say that it can be detected as long, double or float?

---

<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: [December 21, 2020, 4:19am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/4 "2020-12-21T04:19:56Z")

</div>

It's picked the smallest "size" mapping for the provided `my_float` value, which is a float.

---

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [December 21, 2020, 4:33am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/5 "2020-12-21T04:33:49Z")

</div>

The documentation is saying:  
string -\> Either a date field (if the value passes date detection), **a double or long field** (if the value passes numeric detection) or a text field, with a keyword sub-field.

There is no mention of the fact that it will strive to choose the smallest "size".

I know it might look like splitting the hair but I am getting tripped with error  
`Bad Request: [status_exception] cannot merge mappings because of differences for field`  
while creating a Analytics Job.

The data is monthly data and I see that for some months the data is mapped a double and for others as float. Hence the question.

---

<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: [December 21, 2020, 4:50am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/6 "2020-12-21T04:50:57Z")

</div>

If you are using dynamic mapping then there may be some differences as Elasticsearch tries to do its best, but it's not guaranteed to be consistent.

Sounds like you should use a mapping template instead.

---

<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: [January 18, 2021, 4:50am UTC](https://discuss.elastic.co/t/is-this-an-error-in-documentation-of-numeric-detection/258944/7 "2021-01-18T04:50:58Z")

</div>

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