How can I implement an autocomplete using redis?
Say for example I have an array ["alfred","joel","jeff","addick"]. When I type a I get ["alfred", "addick"]
I hope you get the point. How can I implement this using redis commands efficiently(if possible but I think it is). It would be great if I could get some simple commands I can try out via telnet to mimic this behaviour.
Thanks
P.S: Merry x-mas to all of you 🙂
If you’re dealing with a large data set, I would suggest considering implementing this as a trie. I have thrown together a small bit of Ruby that would do this:
For example:
Read more on Tries at Wikipedia’s entry on Tries.
You will definitely want to optimize your suggest method to not return ALL values, instead only returning the first X values it finds. It would defeat the purpose to iterate the entire data structure.