Does "IN" is reserved keyword in redis? #3419
Replies: 2 comments
-
Please ask in RediSearch or RedisJSON |
Beta Was this translation helpful? Give feedback.
0 replies
-
ok. Thanks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Does IN is reserved keyword in redis? Because in my case, when json data contains string which is starting with “IN” and also contains special character in it (e.g. IN-hemangiblpt) then there is no need to escape that special character during search. But if string started other than IN and contains special character then i need to escape it in data aswell as in query.
This is my redis data which contains 2 JSON keys with different name.
JsonValue is
{
name:"IN-hemangiblpt"
ip:"192.168.31.144"
token:"90009f26-b05b-4d87-99c0-db7290db081a"
isAliveTill:"2023-05-16T10:09:40.011Z"
}
JsonValue is
{
name:"hemangib-lpt"
ip:"192.168.31.145"
token:"af1a9aee-c623-4316-90a0-c443a78ebf56"
isAliveTill:"2023-05-16T10:08:20.013Z"
}
Index on redis for AgentData :
Search Result for all AgentData using query as *
When name field starts with IN, and if it contains characters like -, there is no need to escape it during search. We get correct result like
Query: > ft.search "idx:AgentData" "@name:IN-hemangiblpt"
Result: 1) "1" 2) "AgentData:af1a9aee-c623-4316-90a0-c443a78ebf56" 3) 1) "$" 2) "{"name":"hemangib-lpt","ip":"192.168.31.145","token":"af1a9aee-c623-4316-90a0-c443a78ebf56","isAliveTill":"2023-05-16T10:08:20.013Z"}"
But if we do search on 2nd data where name string doesn’t starts with IN but contains - in it, then search result failed to return data.
Query : > ft.search "idx:AgentData" "@name:hemangib-lpt"
Result: 1) "0"
If we need to search second record, then we need to escape that character in redis db and need to pass query also with escape string like
Data in redis with escape string:
{
name:"hemangib-lpt"
ip:"192.168.31.145"
token:"af1a9aee-c623-4316-90a0-c443a78ebf56"
isAliveTill:"2023-05-16T10:08:20.013Z"
}
Query : > ft.search "idx:AgentData" "@name:hemangib\-lpt"
Result : 1) "1" 2) "AgentData:af1a9aee-c623-4316-90a0-c443a78ebf56" 3) 1) "$" 2) "{"name":"hemangib\\-lpt","ip":"192.168.31.145","token":"af1a9aee-c623-4316-90a0-c443a78ebf56","isAliveTill":"2023-05-16T10:08:20.013Z"}
Beta Was this translation helpful? Give feedback.
All reactions