I feel like the biggest challenge in this problem is searching the keys for substrings or partial matches of what the user enters into a search.
If the code was supposed to take exact and literal text then this problem would be quite simple but as it stands now, I think the biggest obstacle to overcome is how we search for the proper key.
A char is any one of 256 values. There's a very simple hash method I learned where you take an int and reverse the bits, adding everything up. This is good because it's degenerate in the sense that a + b + c will hash to the same value as c + a + b or any permutation thereof.
Adding up the number of characters in the string can easily be stored in an unsigned type or an unsigned long or even the long long!
Where am I going with all this? Well, my mind is a bit scattered atm but I read this paper on hashing on the GPU and I think the algorithm is simple enough that we can apply it to this situation.
Here's the paper : http://idav.ucdavis.edu/~dfalcant//d...ssertation.pdf
The section of interest is the chaining section because of how it works. The idea here is to use buckets. Each key denotes a bucket by a unique ID (hence hashing the keys themselves). We hash the keys to make a bucket and then we fill the bucket with the proper contents.
I think if we used the simple hash function I posted above, we would be able to find some good partial matches. I'm going to test right now and post back with results. The idea is, for a given key, we hash it and compare it to the bucket IDs and for any buckets in the general vicinity, we check for how well it matches.