"term" query fails to match exact long integer; instead matches nearby long integer


(John Freeman) #1

I've got a document with a long integer identifier:

{
"id": -6001495857799773000
}

Trying to filter based on this identifier returns nothing:

{
"query": {
"filtered": {
"filter": {
"term": {"id": -6001495857799773000}
}
}
}
}

I switched to a range query and expanded the range to 1000 numbers on each
side. I hit the document I expected. Through narrowing the range, I found a
number that the term query will exactly match against the document:

{
"query": {
"filtered": {
"filter": {
"term": {"metric.batchId": -6001495857799773137}
}
}
}
}

You can see this number is 137 less than the actual number returned in the
document. This number works for both range (with lte and gte both set to
this number) and term queries. What is going on here?

--
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/fba1325b-91aa-443c-a9d9-8e0c081419ce%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(John Freeman) #2

For the purposes of the example, "metric.batchId" should be just "id".

--
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/24ce4b1c-7410-4931-939d-875b8c092cb8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(John Freeman) #3

So ES is storing the exact integer and matching against it, but does not
show the exact integer in the returned document. How can I get that?

--
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/d5bc77c8-a36f-45dd-bddd-c6fbeae44e35%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly-2) #4

I'm curious about the exact environment you are running these commands
from. I tested it quickly (ES 1.0.1) and it works fine for me from the curl
command-line (i.e. I index the value, it mapped automatically to long, and
queried it back it gave the same value).

I've heard cases where some people executing this in a browser script
environment where big (or small) numbers were not working quite right due
to browser limitations.

I'd double check from the command line to verify if indeed this is the case
for you.

--
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/7e504e5c-d1c9-4ad7-9890-68e01ff9a48e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(John Freeman) #5

I am using 1.0.0.Beta2, with an explicit mapping, and ran this in the Sense
plugin. I will try from command line.

--
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/044f44c6-dc0c-4765-a786-f2fc917e258b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(John Freeman) #6

The hit from the command line has the same wrong integer, but I cannot
repeat this problem using a new index. Could it be corruption? Some of my
other indices were corrupted because of node thrashing: new nodes kept
being started after updating to 1.0.1 because I didn't know the command
line options and default behavior were changed (!!!).

--
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/d0465fc9-ce73-4ff5-9154-568619a5565e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #7