经过大量 搜索 之后,我发现了一篇关于我在StackOverflow上要求的内容的好帖子:
- http://robots.thoughtbot.com/post/48851498400/redis-partial-word-match-you-auto-complete-me
摘要…:
1.为标签创建键值
sadd mysite:tags "stackoverflow" "stack-exchange" "question" "about-redis"
2.为每个可能的组合创建一个索引
是的,例如:
- “ s”
- “ st”
- “ sta”
- … 等等
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
… 等等。
这是关于添加所有以 s , st 开头的标签的…
3.使用SORT获取标签建议:
sort mysite:tags:index:s by nosort get tags:*
这将输出:
- 堆栈溢出
- 堆栈交换
或者…按nosort排序mysite:tags:index:stack-取得标签:*
…将输出:
- 堆栈交换
这似乎是一个很好的解决方案!



