Open sanikolaev opened 10 months ago
select * from t where double(f.a) < 8589934593.1
--------------
Empty set (0.00 sec)
doesn't work too.
Probably, this behavior is expected since the numbers with floating point which we pass to compare are treated as floats. By default, Elastic produces similar results in this case unless you explicitly set the type of object property as double:
curl -X PUT -H 'Content-Type: application/json' localhost:9200/test -d '{
"mappings": {
"properties": {
"f": {
"type": "object"
}
}
}
}'
curl -H 'Content-Type: application/json' elastic:9200/test/_doc -d '{
"f": {"a": 8589934592.1 }
}'
curl -H 'Content-Type: application/json' elastic:9200/test/_search -d '{
"query": {
"range": {
"f.a": {
"lt": 8589934593.1
}
}
} }'
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}}
unless you explicitly set the type of object property as double
Please provide an example.
curl -X PUT -H 'Content-Type: application/json' localhost:9200/test -d '{
"mappings": {
"properties": {
"f": {
"properties": {"a": {"type":"double"}}
}
}
}
}'
curl -H 'Content-Type: application/json' elastic:9200/test/_doc -d '{
"f": {"a": 8589934592.1 }
}'
curl -H 'Content-Type: application/json' elastic:9200/test/_search -d '{
"query": {
"range": {
"f.a": {
"lt": 8589934593.1
}
}
} }'
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"test","_id":"XmF_HI0BR3QhqisR62K1","_score":1.0,"_source":{
"f": {"a": 8589934592.1 }
}}]}}
Expected: since 8589934593.1 is by 1 greater than 8589934592.1 the doc should be matched.