Search using a large value of "long"


(Arinto Murdopo) #1

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:

curl -XGET
"http://eshost:9200/my_index/my_type/_search?q=did:433036615015882750"

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"

curl -XGET "http://eshost:9200/my_index/my_type/_search?q=user.uid:67483951"

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9bc36672-cdcb-4edf-ae04-9bfaa49e7cca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Arinto Murdopo) #2

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:

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=did:433036615015882750"

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"

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=user.uid:67483951"

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/824a0a51-339f-4061-a0df-16add6e43554%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #3

I didn't try on 0.90.9, but I just tried on 1.0 and this query works fine
and returns the document correctly:

http://localhost:9200/foo/doc/_search?q=foo:433036615015882750

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f4da5f6a-681f-4e69-97e6-ffbc7fc4d5ee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrien Grand) #4

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?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html

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:

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=did:433036615015882750"

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"

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=user.uid:67483951"

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/9bc36672-cdcb-4edf-ae04-9bfaa49e7cca%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4BGQXoT_ZpkZszbvjy_TrfY8CnF0s7ZTxO_-o0A95MVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Arinto Murdopo) #5

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.

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:

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?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html

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:

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=did:433036615015882750"

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"

curl -XGET "
http://eshost:9200/my_index/my_type/_search?q=user.uid:67483951"

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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/9bc36672-cdcb-4edf-ae04-9bfaa49e7cca%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/acb0e42a-e967-401e-9644-398e88e37317%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrien Grand) #6

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.

If you're interested, you can take a look at the Sense screenshot which
highlight the problem in my note:
https://www.evernote.com/shard/s115/sh/a82222fb-952a-4fc0-a81c-2d88c1e2bdb1/bd80a433dfdf0ccb51dd8d35cd827838

Best regards,

Arinto

On Friday, February 14, 2014 7:23:27 AM UTC+8, Adrien Grand wrote:

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?
http://www.elasticsearch.org/guide/en/elasticsearch/
reference/current/indices-get-field-mapping.html

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:

curl -XGET "http://eshost:9200/my_index/my_type/_search?q=did:
433036615015882750"

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"

curl -XGET "http://eshost:9200/my_index/my_type/_search?q=user.uid:
67483951"

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.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/9bc36672-cdcb-4edf-ae04-9bfaa49e7cca%
40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/acb0e42a-e967-401e-9644-398e88e37317%40googlegroups.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7pbkiddy94Dz4MnpDGOzoPEfpHDia8yRO%3Dvbh%3DBOos1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #7