RedisJSON / RedisJSON2

Rust based RedisJSON implementation - Deprecated and moved to RedisJSON/RedisJSON
https://redisjson.io
Other
54 stars 4 forks source link

Add support of JsonPath filter (script) expression to JSON.GET #79

Closed pavelsr closed 4 years ago

pavelsr commented 4 years ago

Hi, I tried to use JsonPath filter expression and got Invalid argument(s) error :

127.0.0.1:6379> JSON.GET d [10]
"{\"code\":\"AAL\",\"coordinates\":{\"lat\":57.028811,\"lon\":9.917771},\"country_code\":\"DK\",\"name\":\"\xe3\x82\xaa\xe3\x83\xbc\xe3\x83\xab\xe3\x83\x9c\xe3\x83\xbc\",\"name_translations\":{\"en\":\"Aalborg\"},\"time_zone\":\"Europe/Copenhagen\"}"
127.0.0.1:6379> JSON.GET d .[?(@.code=='AAL')]
Invalid argument(s)
127.0.0.1:6379> JSON.GET d .[(@.code=='AAL')]
Invalid argument(s)

Seems like filter expressions is not supported yet, right ? If it's supported - please provide example. Thanks a lot.

gkorland commented 4 years ago
127.0.0.1:6379> json.set user1 . '{"last":"Joe", "first":[{"code":"1"}, {"code":"2"}]}' 
OK
127.0.0.1:6379> json.get user1 "$.first[?(@.code==\"2\")]"
"{\"code\":\"2\"}"
pavelsr commented 4 years ago

Hi @gkorland

Thanks for explanation, this works.

Btw, when using $ symbol redis crashed (without it works fine)

127.0.0.1:6379> json.set user2 . '[{"code":"1"}, {"code":"2"}]'
OK
127.0.0.1:6379> json.get user2 ".[?(@.code==\"2\")]"
"{\"code\":\"2\"}"
127.0.0.1:6379> json.get user2 "$.[?(@.code==\"2\")]"
# redis-cli closed and redis docker container crashed

I use latest docker redislabs/redisjson2 image.

gkorland commented 4 years ago

thanks! we'll fix it