Closed fstarr closed 4 years ago
Thanks for the issue!
@fstarr the right way to query numeric fields is using range queries in your example it should be:
127.0.0.1:6379> "JSON.QGET" "users" "@age:[33,33]"
"{\"user2\":[{\"first\":\"Kevin\",\"last\":\"Smith\",\"age\":33}]}"
The query language is following RediSearch query syntax See: https://oss.redislabs.com/redisearch/Query_Syntax.html
@gkorland Thanks! For integer values this works as expected! But unfortunately it does not work for float numbers. :(
Changing the age of the example dataset above to 33.1 and rerunning the query again yields no results:
127.0.0.1:6379> "JSON.QGET" "users" "@age:[33.1,33.1]"
"{}"
Might be a floating point number comparison problem that probably is unrelated to RedisJSON2:
127.0.0.1:6379> "JSON.QGET" "users" "@age:[33.0,33.2]"
"{\"user2\":[{\"first\":\"Kevin\",\"last\":\"Smith\",\"age\":33.1}]}"
Hi,
May I have a question that: does redisJSON2 runs depends on redisSearch? I mean we do need to also prepare loading redisSearch so lib ?
Yes it does depends on RediSearch. But, no need to also load load RediSearch so, it packs RediSearch logic as part of RedisJSON2 so.
Hello,
May I have another question: Is it possible to query a field that is inside another obj? Like this:
172.17.0.1:7001> "JSON.SET" "user4" "." "{\"first\": \"Will\", \"last\": \"Smith\", \"location\": {\"city\": \"Florianopolis\", \"uf\": \"SC\"}}" "INDEX" "users"
I want to find every location.uf = SC. Like a "@location.uf:SC"
Sure you should add an index on location.uf
and then you can query.
JSON.INDEX add users uf $.location.uf
JSON.QGET users "@uf:SC"
BTW for questions you might want to use the group https://groups.google.com/forum/#!forum/redisjson
@gkorland I saw you're quite active over at RediSearch. Do you happen to know if this issue regarding floating point range queries is already known there? If not, would it be ok to repost the issue there (with the above RedisJSON2 reproducer)? Maybe there's a way to link the discussion of this thread too.
We are already discussing it on RediSearch. I just opened this issue the other day https://github.com/RediSearch/RediSearch/issues/1080
Hi,
thanks for providing the community with the RedisJSON2 extension!
TL;DR
The indexing (or querying) mechanism of RedisJSON2 does not seem to work for non-string fields.
Could this be fixed, so that
JSON.QGET
also allows queries involving non-string fields?Detailed description (including reproducer) follows
I'm creating an index
users
as follows and insert two data sets:Next I'm executing a query asking for all users whose last names start with "smi":
The query returns all users as expected:
However when asking for users with an age of 33:
Nothing is returned:
If I insert a third user with an age specified as string (note the difference to the
user2
insertion):And rerun the query:
The data set for
user3
is returned.This observation leads to the conclusion that the indexing (or querying) mechanism of RedisJSON2 does not work for non-string fields.
Could this be fixed, so that
JSON.QGET
also allows queries involving non-string fields, like the one I created foruser2
?Following you'll find my reproducer script that was hacked together in Python. I used
redis-cli monitor
to monitor the actual commands hitting redis as shown above.