# Problem with "long" type field

**URL:** <https://discuss.elastic.co/t/problem-with-long-type-field/23458>\
**Category:** Elasticsearch\
**Created:** [April 29, 2015, 3:02am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458 "2015-04-29T03:02:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stabaoc](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stabaoc](https://discuss.elastic.co/u/Stabaoc)\
**Post date:** [April 29, 2015, 3:02am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/1 "2015-04-29T03:02:16Z")

</div>

I meet a problem . When I index an value , for example {"id":  
-8848340816900692111},  
then i search it ,it shows that "id": -8848340816900692000.  
Anyone can help? I want know why does elasticsearch do this and how can i  
deal with.  
Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7753596d-31e6-4e6d-abe6-1945c9b8bd39%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7753596d-31e6-4e6d-abe6-1945c9b8bd39%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 29, 2015, 3:43am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/2 "2015-04-29T03:43:42Z")

</div>

It typically happens if you put data into elasticsearch using Sense or some  
other JavaScript-based applications. Large numbers like this one are  
getting rounded in JavaScript before they reach Elasticsearch. Please see

> <https://github.com/elastic/elasticsearch/issues/5518#issuecomment-38540645>
>
> Insert a document :
> 
> \<pre\>
> PUT test/Test/1
> {
> "value" : 1201169796353347552
> }…
> \</pre\>
> 
> Get it : 
> 
> \<pre\>
> GET test/Test/1
> \</pre\>
> 
> The received value for the field is : 1201169796353347600.
> When searching, only '1201169796353347552' - the original value must be used in order to get the document.

for more information about the issue.

On Tuesday, 28 April 2015 23:02:16 UTC-4, Stabaoc wrote:

> I meet a problem . When I index an value , for example {"id":  
> -8848340816900692111},  
> then i search it ,it shows that "id": -8848340816900692000.  
> Anyone can help? I want know why does elasticsearch do this and how can i  
> deal with.  
> Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e12eb941-fe3c-43d3-931d-2efea9577525%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e12eb941-fe3c-43d3-931d-2efea9577525%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Stabaoc](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stabaoc](https://discuss.elastic.co/u/Stabaoc)\
**Post date:** [April 29, 2015, 5:28am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/3 "2015-04-29T05:28:40Z")

</div>

Thanks a lot!Help much!

在 2015年4月29日星期三 UTC+8上午11:43:42，Igor Motov写道：

> It typically happens if you put data into elasticsearch using Sense or  
> some other JavaScript-based applications. Large numbers like this one are  
> getting rounded in JavaScript before they reach Elasticsearch. Please see  
> [Long field is rounded · Issue #5518 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/5518#issuecomment-38540645)  
> for more information about the issue.
> 
> On Tuesday, 28 April 2015 23:02:16 UTC-4, Stabaoc wrote:
> 
> > I meet a problem . When I index an value , for example {"id":  
> > -8848340816900692111},  
> > then i search it ,it shows that "id": -8848340816900692000.  
> > Anyone can help? I want know why does elasticsearch do this and how can i  
> > deal with.  
> > Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cc260c9d-fb09-4a5d-96f9-a79c728cab5a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cc260c9d-fb09-4a5d-96f9-a79c728cab5a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Stabaoc](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stabaoc](https://discuss.elastic.co/u/Stabaoc)\
**Post date:** [April 29, 2015, 6:24am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/4 "2015-04-29T06:24:18Z")

</div>

So I can't use Java Api?

在 2015年4月29日星期三 UTC+8上午11:43:42，Igor Motov写道：

> It typically happens if you put data into elasticsearch using Sense or  
> some other JavaScript-based applications. Large numbers like this one are  
> getting rounded in JavaScript before they reach Elasticsearch. Please see  
> [Long field is rounded · Issue #5518 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/5518#issuecomment-38540645)  
> for more information about the issue.
> 
> On Tuesday, 28 April 2015 23:02:16 UTC-4, Stabaoc wrote:
> 
> > I meet a problem . When I index an value , for example {"id":  
> > -8848340816900692111},  
> > then i search it ,it shows that "id": -8848340816900692000.  
> > Anyone can help? I want know why does elasticsearch do this and how can i  
> > deal with.  
> > Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fbb8fe57-cbad-49b9-b13c-6280e7a85c55%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fbb8fe57-cbad-49b9-b13c-6280e7a85c55%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 29, 2015, 1:56pm UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/5 "2015-04-29T13:56:35Z")

</div>

What I was trying to say is that the problem is with browsers parsing json.  
I am not really sure how you jumped to the conclusion that you cannot use  
Java API. Java API doesn't have any of these issues since it is using the  
same representation for long as the rest of elasticsearch. JavaScript on  
another hand is using a different internal representation of long numbers,  
so when you ask JavaScript to parse number -8848340816900692111 it loads it  
as -8848340816900692000. Try parsing your document using  
[http://www.jsoneditoronline.org/](http://www.jsoneditoronline.org/) and you will see what I mean.

On Wednesday, 29 April 2015 02:24:18 UTC-4, Stabaoc wrote:

> So I can't use Java Api?
> 
> 在 2015年4月29日星期三 UTC+8上午11:43:42，Igor Motov写道：
> 
> > It typically happens if you put data into elasticsearch using Sense or  
> > some other JavaScript-based applications. Large numbers like this one are  
> > getting rounded in JavaScript before they reach Elasticsearch. Please see  
> > [Long field is rounded · Issue #5518 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/5518#issuecomment-38540645)  
> > [https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Felastic%2Felasticsearch%2Fissues%2F5518%23issuecomment-38540645&sa=D&sntz=1&usg=AFQjCNFznSzDQEOcZbgWn0lj7SzowuUfzw](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Felastic%2Felasticsearch%2Fissues%2F5518%23issuecomment-38540645&sa=D&sntz=1&usg=AFQjCNFznSzDQEOcZbgWn0lj7SzowuUfzw)  
> > for more information about the issue.
> > 
> > On Tuesday, 28 April 2015 23:02:16 UTC-4, Stabaoc wrote:
> > 
> > > I meet a problem . When I index an value , for example {"id":  
> > > -8848340816900692111},  
> > > then i search it ,it shows that "id": -8848340816900692000.  
> > > Anyone can help? I want know why does elasticsearch do this and how can  
> > > i deal with.  
> > > Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fa58ef0d-7a99-4840-9ac0-fd7f78dd44ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa58ef0d-7a99-4840-9ac0-fd7f78dd44ca%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:17am UTC](https://discuss.elastic.co/t/problem-with-long-type-field/23458/6 "2017-07-06T00:17:02Z")

</div>


