Suppose I have this document:
{
"user": {
"uid": 67483951,
},
"did": 433036615015882750
}
"uid" and "did" have type of "long" in the mapping.
Its document id is unknown and I would like to fetch the document using
"did" value via search API.
Therefore, I issue this curl command:
Unfortunately, the above curl command is unable to fetch my document. Here
is the result from the curl command:
{
"took": 46,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
However, when I use the "uid" to search, I'm able to fetch the document.
Here's the curl command for search using "uid"
I tried above with using Java API (using prepareSearch method of transport
client, with term query), but the results are the same i.e. I can fetch
using "uid" but I can't fetch using "did". So, the question is how to
search using large value of "long" as shown in this case?
Oh, I forgot to mention. I'm using Elasticsearch 0.90.9
On Thursday, February 13, 2014 4:05:12 PM UTC+8, Arinto Murdopo wrote:
Hi there,
Suppose I have this document:
{
"user": {
"uid": 67483951,
},
"did": 433036615015882750
}
"uid" and "did" have type of "long" in the mapping.
Its document id is unknown and I would like to fetch the document using
"did" value via search API.
Therefore, I issue this curl command:
Unfortunately, the above curl command is unable to fetch my document. Here
is the result from the curl command:
{
"took": 46,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
However, when I use the "uid" to search, I'm able to fetch the document.
Here's the curl command for search using "uid"
I tried above with using Java API (using prepareSearch method of transport
client, with term query), but the results are the same i.e. I can fetch
using "uid" but I can't fetch using "did". So, the question is how to
search using large value of "long" as shown in this case?
Can you check that this field is actually mapped as a long (as opposed to
an integer or double) using the get field mapping API?
Since 433036615015882750 requires 59 bits to be stored, it can actually
only be stored as a long (64 bits). Neither an integer (32 bits) nor a
double (52 bits) would be able to store it and it would prevent you from
searching this document.
On Thu, Feb 13, 2014 at 9:05 AM, Arinto Murdopo arinto@gmail.com wrote:
Hi there,
Suppose I have this document:
{
"user": {
"uid": 67483951,
},
"did": 433036615015882750
}
"uid" and "did" have type of "long" in the mapping.
Its document id is unknown and I would like to fetch the document using
"did" value via search API.
Therefore, I issue this curl command:
Unfortunately, the above curl command is unable to fetch my document. Here
is the result from the curl command:
{
"took": 46,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
However, when I use the "uid" to search, I'm able to fetch the document.
Here's the curl command for search using "uid"
I tried above with using Java API (using prepareSearch method of transport
client, with term query), but the results are the same i.e. I can fetch
using "uid" but I can't fetch using "did". So, the question is how to
search using large value of "long" as shown in this case?
For the mapping, it's a "long". Here are the output
{
"my_index": {
"my_type": {
"id": {
"full_name": "id",
"mapping": {
"id": {
"type": "long"
}
}
}
}
}
}
After I do further investigation, it seems that the error is caused by Sense
Chrome pluginhttps://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbothat I use. So, what I did now is I index a document that has an id field
equals to "427478922591096833". When we use obtain this document, the Sense
will show the id equals to "427478922591096800". But, I managed to get the
correct result when using curl.
So yesterday problem is because I used the id (which is the invalid id,
i.e. 427478922591096800) returned by Sense to perform the search and the
search return nothing. When I use the search using the correct id from
curl, I managed to get the document.
If you're interested, you can take a look at the Sense screenshot which
highlight the problem in my note:
Best regards,
Arinto
On Friday, February 14, 2014 7:23:27 AM UTC+8, Adrien Grand wrote:
Since 433036615015882750 requires 59 bits to be stored, it can actually
only be stored as a long (64 bits). Neither an integer (32 bits) nor a
double (52 bits) would be able to store it and it would prevent you from
searching this document.
On Thu, Feb 13, 2014 at 9:05 AM, Arinto Murdopo <ari...@gmail.com<javascript:>
wrote:
Hi there,
Suppose I have this document:
{
"user": {
"uid": 67483951,
},
"did": 433036615015882750
}
"uid" and "did" have type of "long" in the mapping.
Its document id is unknown and I would like to fetch the document using
"did" value via search API.
Therefore, I issue this curl command:
Unfortunately, the above curl command is unable to fetch my document.
Here is the result from the curl command:
{
"took": 46,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
However, when I use the "uid" to search, I'm able to fetch the document.
Here's the curl command for search using "uid"
I tried above with using Java API (using prepareSearch method of
transport client, with term query), but the results are the same i.e. I can
fetch using "uid" but I can't fetch using "did". So, the question is how to
search using large value of "long" as shown in this case?
Oh, I think I understand what the issue is: in javascript there are no
integer types so all numbers are actually floating-point numbers.
433036615015882750 got replaced by 427478922591096800 because it requires
59 bits to be stored while doubles store the value on 52 bits (and the sign
on one bit and the exponent on 9 bits) so the low-order bits got lost. I
think this is a limitation when using Javascript as a client in general,
not only in Sense.
On Fri, Feb 14, 2014 at 4:16 AM, Arinto Murdopo arinto@gmail.com wrote:
Thanks for the prompt reply.
For the mapping, it's a "long". Here are the output
{
"my_index": {
"my_type": {
"id": {
"full_name": "id",
"mapping": {
"id": {
"type": "long"
}
}
}
}
}
}
After I do further investigation, it seems that the error is caused by Sense
Chrome pluginhttps://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbothat I use. So, what I did now is I index a document that has an id field
equals to "427478922591096833". When we use obtain this document, the Sense
will show the id equals to "427478922591096800". But, I managed to get the
correct result when using curl.
So yesterday problem is because I used the id (which is the invalid id,
i.e. 427478922591096800) returned by Sense to perform the search and the
search return nothing. When I use the search using the correct id from
curl, I managed to get the document.
Since 433036615015882750 requires 59 bits to be stored, it can actually
only be stored as a long (64 bits). Neither an integer (32 bits) nor a
double (52 bits) would be able to store it and it would prevent you from
searching this document.
On Thu, Feb 13, 2014 at 9:05 AM, Arinto Murdopo ari...@gmail.com wrote:
Hi there,
Suppose I have this document:
{
"user": {
"uid": 67483951,
},
"did": 433036615015882750
}
"uid" and "did" have type of "long" in the mapping.
Its document id is unknown and I would like to fetch the document using
"did" value via search API.
Therefore, I issue this curl command:
Unfortunately, the above curl command is unable to fetch my document.
Here is the result from the curl command:
{
"took": 46,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
However, when I use the "uid" to search, I'm able to fetch the
document. Here's the curl command for search using "uid"
I tried above with using Java API (using prepareSearch method of
transport client, with term query), but the results are the same i.e. I can
fetch using "uid" but I can't fetch using "did". So, the question is how to
search using large value of "long" as shown in this case?
--
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 elasticsearc...@googlegroups.com.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.