user1102018
user1102018

Reputation: 4451

How can I search users by first and last names in MongoDB/Python/Django

I'm using MongoDB to store a few millions of user documents.
Each document has a first_name and last_name key (column).
The visitor of the website has a single text box for querying the DB for users.
My goal is that inputs like:
John Doe and
Doe John and
Dow Jones
should return a list of possible names, such as:
John Doe, Doe John, Dow Jones, Joan Doe, Johan Dow etc...
Meaning, first_name/last_name-insensitive and 'sounds-like' names should be returned.

How can this be done?

Edit: I don't HAVE to do it in the DB engine. App level searching is acceptable as well.

Upvotes: 0

Views: 240

Answers (1)

Stennie
Stennie

Reputation: 65333

There are a number of phonetic algorithms relevent to implementing "sounds like" matching. These have varying effectiveness depending on cultural differences such as spelling, pronunciation, and languages used within your corpus of names.

A recent article Using Fuzzy Matching to Search by Sound with Python provides a helpful overview of some available options:

Upvotes: 1

Related Questions