5 ms·
Auto Complete with Redis (2010)
- stablemap 9y agoI’m glad to learn of this, but note that it’s from 2010.
- wickedlogic 9y agoThe good news, it more popular now than before... sigh. https://hn.algolia.com/?query=Auto%20Complete%20with%20Redis&sort=byDate&dateRange=all&type=story&storyText=false&prefix&page=0 https://hn.algolia.com/?query=Auto%20Complete%20with%20Redis...
- zachrose 9y agoIs this not a perfect use case for a trie? Can you make a trie in Redis?
- jshen 9y agoI think so, specifically a ternary search tree. While you can implement one on top of redis, I’m pretty sure it would be significantly slower than an in memory TST.
- yeswecatan 9y agoI have not implemented a trie myself, but apparently the problem is they take up a lot of space: http://www.drdobbs.com/database/ternary-search-trees/184410528 http://www.drdobbs.com/database/ternary-search-trees/1844105...
- dvirsky 9y agoA trie and a ternary search tree are two very different beasts. Tries can are very memory efficient, as common prefixes in terms are bunched together, and nodes are not split on every letter.
- rubyn00bie 9y agoWhile i deeply love redis and have used this exact article in the past to build an autocomplete— I’d really not recommend it to anyone. Using something like elastic search provides much better and robust results. Yes it’s more work to setup but the maintenance and tweaking will be waaaay easier and more timely in the long run.
- notimetorelax 9y agoIDK, having survived many ... MANY ES outages, I’d take REDIS in a heartbeat if it gives me the functionality I need.
- fernandotakai 9y agoit's amazing how every single person i know that used ES has had a freakton of bad experiences with ES. and it's still the only ok solution in this area.
- hadsed 9y agoWhat about Solr?
- hardwaresofton 9y agoAlso, SQLite Full Text Search with a prefix query (you could also use `:memory:` as the address to simulate in-memory redis life): https://sqlite.org/fts3.html https://sqlite.org/fts3.html (and also https://sqlite.org/fts5.html https://sqlite.org/fts5.html) -- make sure to use the a stemming tokenizer as well. Why SQLite might be a good idea for your project/small service: https://www.sqlite.org/whentouse.html https://www.sqlite.org/whentouse.html
- kuschku 9y agoActually, at that point you’d want to use PostgreSQL’s Full Text Search. SQLite’s is a lot more limited in performance, and a lot less usable.
- diegorbaquero 9y agoCan we please put [2010] in the title?
- keerthivar 9y agoactually good idea
- antirez 9y agoHello! This article is serverely stale info. Modern versions of Redis with lexicographic ranges can do much better. Please check the following: https://redis.io/topics/indexes https://redis.io/topics/indexes Also you may want to check the RediSearch module from Redis Labs. It's AGPL and not part of the Redis project itself but it's very powerful. http://redisearch.io http://redisearch.io BTW using vanilla Redis with lexicographic ranges some time ago I published a demo where I indexed the whole Linux kernel code using a small amount of memory and performing many tens of thousands ranges per second. There are other systems out there that are designed just for search but in certain low latency cases Redis can be hard to beat, also if you want to change the index in real time.
- jasode 9y ago>This article is serverely stale info. Modern versions of Redis with lexicographic ranges can do much better. Please check the following: https://redis.io/topics/indexes https://redis.io/topics/indexes Are you able to put a similar warning at the top of the article? Maybe something like, "[The following info is deprecated but is left for historical purposes. ... Please check the following: https://redis.io/topics/indexes]" https://redis.io/topics/indexes]"
- antirez 9y agoYou are right, I usually always do that but this time I totally missed this. Thanks I'll do.