# Java Long serialisation

**URL:** <https://discuss.elastic.co/t/java-long-serialisation/29831>\
**Category:** Elasticsearch\
**Created:** [September 23, 2015, 10:00am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831 "2015-09-23T10:00:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![natani](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@natani](https://discuss.elastic.co/u/natani)\
**Post date:** [September 23, 2015, 10:00am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/1 "2015-09-23T10:00:53Z")

</div>

I am using

`BulkProcessor` Java classes's method `setSource ( Map < String, Object > )` .

one of the object I am sending is a java `Long` with value `4188977024190880439` but when I look it up in the kibana, the value that it shows is `4188977024190880300`.

This is happening with most of the values also, the last three digits seems to be generated at random or something.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 23, 2015, 11:07am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/2 "2015-09-23T11:07:20Z")

</div>

What's the field's mapping? It sounds like it might be mapped as a double instead of a long.

---

<div class="post-metadata">

**Author:** ![natani](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@natani](https://discuss.elastic.co/u/natani)\
**Post date:** [September 24, 2015, 8:26am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/3 "2015-09-24T08:26:47Z")

</div>

Yes. It is double, but that shouldn't be a problem, right? I didn't define mapping myself, I just let the ES decide the mapping.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 24, 2015, 8:31am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/4 "2015-09-24T08:31:32Z")

</div>

The fact that it's mapped as a double is precisely the problem. An IEEE double value holds about 16 digits of precision, and it's indeed the 17th digit that's different in your case. You need to make sure the field is mapped as a long.

---

<div class="post-metadata">

**Author:** ![natani](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@natani](https://discuss.elastic.co/u/natani)\
**Post date:** [September 24, 2015, 8:38am UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/5 "2015-09-24T08:38:18Z")

</div>

Cool. Thanks man!! Will change it to Long. 🙂

---

<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 5, 2017, 11:48pm UTC](https://discuss.elastic.co/t/java-long-serialisation/29831/6 "2017-07-05T23:48:17Z")

</div>


