Comments (9)
@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.
from manticoresearch.
double(f.a)
doesn't work:
mysql> drop table if exists t; create table t(f json); insert into t(id,f) values(1,'{"a":2.5}'); select * from t where double(f.a) <= 2;
--------------
drop table if exists t
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
create table t(f json)
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t(id,f) values(1,'{"a":2.5}')
--------------
Query OK, 1 row affected (0.00 sec)
--------------
select * from t where double(f.a) <= 2
--------------
+------+----------------+
| id | f |
+------+----------------+
| 1 | {"a":2.500000} |
+------+----------------+
1 row in set (0.00 sec)
--- 1 out of 1 results in 0ms ---
from manticoresearch.
seems the right form that works now is the
select * from t where f.a <= 2.0;
Empty set (0.00 sec)
--- 0 out of 0 results in 0ms ---
from manticoresearch.
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.
from manticoresearch.
It looks like the correct float comparison can be guaranteed for int numbers with less than 7 digits
Is this what you mean by the general theory of float comparison or you mean our specific case?
from manticoresearch.
mysql > select * from t where f.a <= 2;
Nick has an idea of converting N
to N.0
in this case when N
is in a specific range. @Nick-S-2018 pls provide more details.
from manticoresearch.
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.
from manticoresearch.
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.
from manticoresearch.
As discussed, we'll implement support for where double(f.a) <= 2
.
from manticoresearch.
Related Issues (20)
- Thai chars are in the wrong charsets HOT 5
- Treating document IDs as numbers in /search responses HOT 4
- Daemon crashes on _search request from Kibana HOT 1
- Fix json escaping for mysqldump HOT 2
- Make it possible to heal from dupes in a disk chunk HOT 3
- Search by JSON keys works incorrectly HOT 1
- Possible issue with Buddy on Windows HOT 6
- buddy can not work at Windows if listen is 127.0.0.1 HOT 5
- WARNING: wordlist size mismatch (size=18, checkpoints=0) HOT 1
- Crash if I use an SQL with a reserved word HOT 4
- Escape is not working for HTTP and SQL HOT 4
- IDF calculation issue
- Extended quote and double quote functionality
- Show correct data types in /cli_json HOT 2
- Escaping in wordforms and exceptions
- Problem with using > HOT 1
- Error: GPG check FAILED when installing in platform linux/arm64 image almalinux:9 HOT 7
- Non exist chunk crash
- Can't import table with wordforms HOT 8
- plain index needs autodetection of date formats for timestamp fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from manticoresearch.