I'm using ServiceStack.Redis to implement a demo project. It contains two POCOs i.e Albums and its Songs.
Below is the search results measured using a stopwatch instance:
Time elapsed searching 5804 items is 00:00:00.1243984 <-- Albums
Time elapsed searching 138731 items is 00:00:02.0592068 <-- Songs
As you can see the search for the songs is taking too much time. I'm displaying the results in a WPF application wherein the search term is also entered. The lag is a no-go for redis.
Below is the code used for searching:
IEnumerable<int> songsFromRedis =
songRedis.GetAll()
.Where(song => song.Title != null
&& song.Title.ToLowerInvariant().Contains(searchText))
.OrderBy(song => song.Title)
.Select(x => x.AlbumId);
If we cannot make it any faster, would ElasticSearch help ?
Any search oriented database would help. Even mysql fulltext search, which is notoriusly slow, would be a lot better here.
Elasticsearch is one good alternative, Sphinx another good one. ES has the easy scalability and ease of use, sphinx has the performance win and otherwise most of the common features but is a bit more work to learn and to scale.