# Elasticsearch indexing wrong value for double fields

**URL:** https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866
**Category:** Elasticsearch
**Created:** [July 27, 2017, 8:31pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866 "2017-07-27T20:31:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![luizgpsantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luizgpsantos/32/608_2.png) [@luizgpsantos](https://discuss.elastic.co/u/luizgpsantos)
#### Post date: [July 27, 2017, 8:31pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866/1 "2017-07-27T20:31:43Z")

</div>

Hello,

I'm facing some issues indexing double fields without quotation marks.

```auto
PUT test
{
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "double" }
            }
        }
    }
}

POST test/type1/1
{
  "field1": 15414001497201083
}

GET test/type1/1

{
  "_index": "test",
  "_type": "type1",
  "_id": "1",
  "_version": 1,
  "found": true,
  "_source": {
    "field1": 15414001497201084
  }
}

```

When using quotation marks it works as expected:

```auto
POST test/type1/1
{
  "field1": "15414001497201083"
}

GET test/type1/1

{
  "_index": "test",
  "_type": "type1",
  "_id": "1",
  "_version": 2,
  "found": true,
  "_source": {
    "field1": "15414001497201083"
  }
}

```

Is it necessary to use quotation marks to index double fields?

Elasticsearch version: 5.5.1

Thank you,  
LG

---

<div class="post-metadata">

### Author: ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)
#### Post date: [July 28, 2017, 6:16am UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866/2 "2017-07-28T06:16:05Z")

</div>

You did not specify what client you are using yet I suspect that that is the problem here. I think that you are using a JavaScript-based client (e.g., Console). The problem is that everything in JavaScript is a IEEE-754 double and `15414001497201083` can not be represented exactly in that representation, the nearest number that can be represented is `15414001497201084` (see this [calculator](http://www.exploringbinary.com/floating-point-converter/)) for example. Therefore, your client is making this conversion _before_ sending the input to Elasticsearch. You could see this if you `tcpdump` the HTTP request to Elasticsearch. If you use say `curl` which is not going to do such a conversion _before_ sending the request to Elasticsearch, you will instead see what you expect.

---

<div class="post-metadata">

### Author: ![luizgpsantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luizgpsantos/32/608_2.png) [@luizgpsantos](https://discuss.elastic.co/u/luizgpsantos)
#### Post date: [July 28, 2017, 12:23pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866/3 "2017-07-28T12:23:43Z")

</div>

Hi @jasontedor you've got the point. First I was using NEST and then tried Console. Using curl it doesn't happen.

Thank you!

---

<div class="post-metadata">

### Author: ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)
#### Post date: [July 28, 2017, 12:38pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866/4 "2017-07-28T12:38:06Z")

</div>

You are very welcome.

---

<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: [August 25, 2017, 12:38pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-wrong-value-for-double-fields/94866/5 "2017-08-25T12:38:36Z")

</div>

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