O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

In this recipe, we used a Redis sorted set for storing the search data. A sorted set stores the data sorted with a score. Each score should be attached with only a single value. Here, we get the name of the stock, such as EcoWise Holdings Ltd, or Eastern Holdings Ltd. We convert them into prefixes, as discussed earlier. Since both the names contain the word "Holdings", we will have a sorted set with a holdi key (remember that we convert all names to lowercase), and two values:

    holdi - score = 0.0, value = 5CT
    holdi - score = 0.0, value = BDT

When we search for the string hold, both the values should be returned. From the values, we find the name from the hash set, and return the set of names. We can further optimize the search ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required