The guys from PlayNice.ly, which are building a bug tracker that uses Redis for storing all app data (users, projects, bugs, comments, audit data, etc.), have posted recently ☞ here and ☞ here about their work to support search within their product.
While the general idea is to simply store the inverted index into Redis, there are a couple of interesting things to be noted:
- Redis native support for
SETdata type and its set operations (union, intersection, difference) makes working with Redis stored reversed indexes pretty handy
- While you might be tempted to use every term as an index key, this will not work with fuzzy searches (i.e. searches for the word “numbers” will not contain documents containing the word “number”). Using “smart keys” — the article mentions using phonetic algorithms for calculating the keys; another solution can employ stemming algorithms — will help you reduce the number of index keys and also to perform fuzzy searches
- Building a good API for working with a custom solution will make things feel more natural.
Anyways, before consider this problem completely solved there are a couple of additional things that you should keep in mind:
- index updates: there are many different scenarios in which you’ll have to update the inverted index and this can raise different problems starting with:
- the increased number of operations (writes explosion) and rountrips to the storage
- dealing with concurrent updates
- index size (or data explosion) : even if the number of keys in the index is limited, the total amount of data stored will grow over time with the number of source documents. Keeping in mind that Redis stores all data in memory the hardware requirements for your machine will be higher. The upcoming Redis version will help alleviate this issue by introducing Redis virtual memory about which you can read more here.