如何在redis中搜索字符串? [英] How do I search strings in redis?

查看:44
本文介绍了如何在redis中搜索字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个自动完成功能.我有一个简短的描述性字符串数据类型的属性.我在 redis 中有一个 id 列表,用于按创建日期排序的数据类型,我使用 id 来设置和获取数据类型的属性,如 redis 类型中所述文档.我不使用哈希表.什么是获得一个的最好方法与输入到自动完成输入中的内容相匹配的一组字符串盒子给出了这个设置?检查所有 ID 并检查属性我想搜索 - 每次击键似乎都是错误的方式这.

I want an autocomplete feature. I have short descriptive strings on a property of a data type. I have a list of ids in redis for the datatype ordered by created date and I use the ids to set and get properties for the datatype as explained in the redis type documentation. I don't use hash tables. What's the best way to get a set of strings matching what's been typed into an autocomplete input box given this setup? Going through all ids and checking the property I want to search - for each keystroke seems like the wrong way to do this.

除了下面的答案,我还看到了这个:

In addition to the answers below, I've been shown this:

http://antirez.com/post/autocomplete-with-redis.html

推荐答案

您需要使用保存任何内容时写入的集合或排序集合来设置索引.

You need to set up an index using sets or sorted sets that you write to when you save anything.

http://web.archive.org/web/20121013063245/http://playnice.ly/blog/2010/05/05/a-fast-fuzzy-full-text-index-using-redis 与我自己使用的非常接近.

There's a good writeup at http://web.archive.org/web/20121013063245/http://playnice.ly/blog/2010/05/05/a-fast-fuzzy-full-text-index-using-redis that is pretty close to what I use myself.

这篇关于如何在redis中搜索字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆