Slide 18
Slide 18 text
前缀匹配搜索过程
r
1
[rails,rake,rubies,ruby]
ru
8
[rubies,ruby]
ruby
13
[ruby]
输入
坐标
得到从坐标 1 到 101 之间的前缀,并取出带 * 号的项
redis> ZRANGE 1 100+1
redis> SORT topic:rubies+ruby BY topic:_score_:* DESC LIMIT 0 10
[2,3,1,4]
返回到 redis-search [2,1] [1]
redis> HMGET ask 2,3,1,4
结果
1. r
2. ra
3. rai
4. rail
5. rails*
6. rak
7. rake*
8. ru
9. rub
10. rubi
11. rubie
12. rubies*
13. ruby*
redis> ZRANK r
rub
9
redis> SUNIONSTORE topic:rubies+ruby topic:rubies topic:ruby
取关键词的并集
排序
{ 'id' : 2, 'name' : 'Rails' , 'score' : 18 }
{ 'id' : 3, 'name' : 'Rubies', 'score' : 10 }
{ 'id' : 1, 'name' : 'Ruby' , 'score' : 5 }
{ 'id' : 4, 'name' : 'Rake', 'score' : 4 }
http://antirez.com/post/autocomplete-with-redis.html
前缀算法索引来源:
11年11月7日星期⼀一