# Adding id with long type changes the actual value

**URL:** <https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473>\
**Category:** Elasticsearch\
**Created:** [May 29, 2017, 3:32pm UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473 "2017-05-29T15:32:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ehtisham\_Ullah](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@Ehtisham\_Ullah](https://discuss.elastic.co/u/Ehtisham_Ullah)\
**Post date:** [May 29, 2017, 3:32pm UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/1 "2017-05-29T15:32:09Z")

</div>

I am trying to figure out why elasticsearch is changing the id field of the document that i am inserting. first i was inserting it with data type integer than i realize the id is too heavy for the integer so i declared the data type with long but I ended up with the same situation. I am getting the same issue.  
id value i get after inserting is 838738379231670300 where it is supposed to be 838738379231670227,  
I think elasticsearch round off the value. Please help needed

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [May 29, 2017, 4:04pm UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/2 "2017-05-29T16:04:58Z")

</div>

Hi,  
Can you check & provide your index mapping ?  
Note that if you don't have created a new index, inserting a new value has no impact on the field format.

bye,  
Xavier

---

<div class="post-metadata">

**Author:** ![Ehtisham\_Ullah](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@Ehtisham\_Ullah](https://discuss.elastic.co/u/Ehtisham_Ullah)\
**Post date:** [May 30, 2017, 7:32am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/3 "2017-05-30T07:32:29Z")

</div>

This is the initial mapping for the fields where I want exact format,  
"mappings": {  
"tweet":  
{  
"properties": {  
"coordinates": {  
"properties": {  
"coordinates": {  
"type": "geo\_point"  
}  
}  
},  
"created\_at":{  
"type": "date",  
"format": "EEE MMM dd HH:mm:ss Z yyyy"  
},  
"id" :  
{  
"type": "long"  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [May 30, 2017, 9:35am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/4 "2017-05-30T09:35:18Z")

</div>

Have you recreate a new index since you have changed your mapping ?

---

<div class="post-metadata">

**Author:** ![Ehtisham\_Ullah](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@Ehtisham\_Ullah](https://discuss.elastic.co/u/Ehtisham_Ullah)\
**Post date:** [May 30, 2017, 10:02am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/5 "2017-05-30T10:02:53Z")

</div>

Yes I have created index after creating mapping id field show the type as long but the issue is still there it roundoff the last 3 digits, as mentioned above.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [May 30, 2017, 10:14am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/6 "2017-05-30T10:14:49Z")

</div>

The mapping looks good, how do you index your datas ? Do you have any errors or warnings in your server log ?

---

<div class="post-metadata">

**Author:** ![Ehtisham\_Ullah](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@Ehtisham\_Ullah](https://discuss.elastic.co/u/Ehtisham_Ullah)\
**Post date:** [May 30, 2017, 10:19am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/7 "2017-05-30T10:19:12Z")

</div>

I figured it out this is happening because of javascript encoding, elasticsearch save and return the exact result but while presenting the stored id field the javascript round off the value in kibana.  
I run some cypher queries from outside kibana in python which received the correct values.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [May 30, 2017, 10:22am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/8 "2017-05-30T10:22:06Z")

</div>

ok, ask on Kibana forum then 😉

---

<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:** [June 27, 2017, 10:22am UTC](https://discuss.elastic.co/t/adding-id-with-long-type-changes-the-actual-value/87473/9 "2017-06-27T10:22:12Z")

</div>

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