Phonetic Algorithm to search Usernames

238 views Asked by At

I got DynamoDB to store user profiles. The primary key here is an id. It is necessary that the key is an id. A user profile contains information like his username, a set of friends,... So now here is the first problem: user A wants to search user B by his name. I dont want to do a full DynamoDB scan each time this happens. Since I already got a redis server I though I could just store username-id-pairs there.

So now the real problem: what do I search for? For example my username could be Eric1996. A friend of mine doesnt remember the last digits so he just searches for Eric19. Or maybe he just forgets the capital letter at the begining and searches for eric1996. In an other case he might misspell the name like erik1996, erick1996, erich1996.

I searched for that topic a bit and learend that there is something called Phonetic algorithms which search words by what they sound. That would fix the example above. But would such algorithms work for other usernames as well? You now some users come up with really 3x0tic names or just use random letters. I know a guy who calls himselfe something like dadddddx__7 online. I assume this is much harder than a spelling corrector since a user might have a name that is misspelled on purpose

1

There are 1 answers

0
DhruvPathak On

Dynamodb or redis is an incorrect tool for your requirements. I would recommend using dyanmodb or redis for your datastore, and use Solr or ElasticSearch ( or their AWS version Amazon CloudSearch, which provides both solr and elasticsearch) You can store your user profiles in dynamodb, and store searchable fields in your search store ( you can even store full profiles in search store). Then search functionalities like spelling errors, ranking friends based on some score are easy to implement.