# Long data type value corruption

**URL:** <https://discuss.elastic.co/t/long-data-type-value-corruption/73614>\
**Category:** Elasticsearch\
**Created:** [February 2, 2017, 2:23am UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614 "2017-02-02T02:23:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![get2sanal](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@get2sanal](https://discuss.elastic.co/u/get2sanal)\
**Post date:** [February 2, 2017, 2:23am UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/1 "2017-02-02T02:23:57Z")

</div>

I am using Elasticsearch version 5.1.2. There is some kind of number overflow when I try to ingest long value close to Long.MAX\_SIZE.  
I have tried the same with ES 2.4 as well. Same issue again.

PUT /library/books/1  
{

"longValue1" : -9223372036854775808,  
"longValue2" : 9223372036854775807

}

GET /library/\_search

This returns:  
{  
"took": 10,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "library",  
"\_type": "books",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"longValue1": -9223372036854776000,  
"longValue2": 9223372036854776000  
}  
}  
]  
}  
}

Value: -9223372036854775808 becomes -9223372036854776000  
Value: 9223372036854775807 becomes 9223372036854776000

Is this an known issue?  
Please advise.

Thanks,  
Sanal

---

<div class="post-metadata">

**Author:** ![BradVido](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradvido/32/741_2.png) [@BradVido](https://discuss.elastic.co/u/BradVido)\
**Post date:** [February 6, 2017, 9:14pm UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/2 "2017-02-06T21:14:02Z")

</div>

Same issue here!

---

<div class="post-metadata">

**Author:** ![njahncke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/njahncke/32/15261_2.png) [@njahncke](https://discuss.elastic.co/u/njahncke)\
**Post date:** [February 6, 2017, 9:46pm UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/3 "2017-02-06T21:46:43Z")

</div>

We use similar long numeric values for internal IDs, but we store them as strings because of this issue. I'm not sure if it will help you, but it works well for us.

---

<div class="post-metadata">

**Author:** ![get2sanal](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@get2sanal](https://discuss.elastic.co/u/get2sanal)\
**Post date:** [February 7, 2017, 5:03am UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/4 "2017-02-07T05:03:34Z")

</div>

If we map the data type as string during ingest, the \_mapping for the respective index/type shows data type as "string" instead of "long" which is expected.

If one needs to retain the \_mapping as "long", is there any way out?

---

<div class="post-metadata">

**Author:** ![njahncke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/njahncke/32/15261_2.png) [@njahncke](https://discuss.elastic.co/u/njahncke)\
**Post date:** [February 7, 2017, 2:04pm UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/5 "2017-02-07T14:04:28Z")

</div>

From what I understand, the issue isn't actually Elasticsearch, which properly supports long values, but rather JavaScript/JSON, which does not. If you can get your data into and out of ES without type conversion problems, you'll be all set. We use JavaScript, so we had to go the string route.

---

<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:** [March 7, 2017, 2:05pm UTC](https://discuss.elastic.co/t/long-data-type-value-corruption/73614/6 "2017-03-07T14:05:27Z")

</div>

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