It would be like StackOverflow: when you ask a question you need to provide some tags.
Currently I'm querying the relational database store, but I believe that Redis should make sense in order to cache tag suggestions.
For example, it would be a set like this:
sadd tags:suggestions "c#" ".net" "redis"
Now some user is asking a question and he/she may write "ne" so there's some tag in the Redis cache that may match the whole partial tag name: .net.
I can't figure out how I would intersect such tags:suggestions
Redis set in order to get ".net".
Or should I use a string instead of a set?
Thank you in advance!
Note:
For those asking "what I've tried so far", please double-check the question: I can't figure out what to do, I'm just learning Redis. What I've tried so far? Reading the manual, trying it using a set, but I came here because I don't know if I can implement such requirement with Redis...
After googling a lot, I found a good post about something that fits what I was asking for here at StackOverflow:
Summary...:
1. Create key-values for tags
2. Create an index for each possible combination
Yes, for example:
... and so on
sadd mysite:tags:index:s 1 2
sadd mysite:tags:index:st 1 2
sadd mysite:tags:index:sta 1 2
sadd mysite:tags:index:stack 1 2
sadd mysite:tags:index:stacko 1
... and so on.
It's about adding all tags that start with s, st...
3. Using SORT to get tags suggestions:
This will output:
Or... sort mysite:tags:index:stack- by nosort get tags:*
...will output:
It seems to be a good solution!