-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong result when searching on json attributes #1724
Comments
@Nick-S-2018 As discussed on today's dev call, please check if type casting works in this case and how applicable it is to be used in the clients. |
|
seems the right form that works now is the
|
It looks like the correct float comparison can be guaranteed for int numbers with less than 7 digits; the limit is 2097152 (the first 22-bit number in binary format). For the numbers less than that conversion to float should work fine, like in the example above; for the larger numbers precision loss appears. |
Is this what you mean by the general theory of float comparison or you mean our specific case? |
Nick has an idea of converting |
Unfortunately, this idea guarantees only the precision for values with a certain number of digits. E.g., '+-2097152' range would fix the issue only for values with one digit after decimal point, like in the original example. The more digits after the point a stored value has, the lesser such range would became. So, this approach does not look effective. |
Elastic always converts the compared value to the data type of the compared field. In case of a JSON object attribute, its type is defined by the detected type of the first inserted value, unless it has been set explicitly on the index creation . By default, Elastic detects numbers with floating points as 'floats', so the compared numeric value will be converted to 'float'. However, if 'double' has been set as the attribute data type, the compared value will be treated as 'double' too. |
As discussed, we'll implement support for |
Describe the bug
Searching on a numeric JSON property produces wrong results.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Empty result.
Actual behavior
+------+----------------+
| id | f |
+------+----------------+
| 1 | {"a":2.500000} |
+------+----------------+
Describe the environment:
Additional context
Search with strict comparison works fine. E.g.,
select * from t where f.a < 2;
indeed produces empty result in the example above.Providing a float value in the search query, e.g.,
select * from t where f.a <= 2.0;
, produces correct results as well.The text was updated successfully, but these errors were encountered: