Can Redis do prefix matching?

Let's say that I have many cities in the world:

EUKLOND
EUKMANC
EUKEDIN
EITROME
EITMILA
EITNAPE
EFRPARI
EFRAVIG
EFRBRES

If the first letter is a continent, the following two countries, and the final 4 - the abbreviated name of the city.

I would like to be able to search for this set by going to “E” which will return all records or EIT and retrieve all records for Italy or EFRPARI and get only the record in Paris.

Can I do something with Redis?

+5
source share
1 answer

This is usually an autocomplete scenario.

Salvatore Sanfilippo (@Antirez) , author of Redis, wrote a detailed blog post on how to do this.

: , Salvatore, , , .

+11

All Articles