I'm just learning metaphone and double metaphone search algorithms, and I have a few questions. On the Metaphone Wiki page, I found several sources with implementations, in particular, the MySQL implementation. I wanted to test it using a test database, so I first imported the metaphone.sql file (containing the double metaphone function) found here
Now I have a table, a country in which there is a list of all countries in the column "name", for example. "Afghanistan", "Albania", "Algeria", etc. So, firstly, I wanted to create a new column in the table to store the double metaphone row of each country. I ran the following code:
UPDATE country SET NameDM = dm(name)
Everything worked correctly. Afghanistan is AFKNSTN, Albania is ALPN, Algeria is ALKR, ALJR, etc. “Amazing,” I thought.
However, when I tried to query the table, I did not get any results. For the author of metaphone.sql, I followed the syntax of the following SQL statement:
SELECT Name FROM tblPeople WHERE dm(Name) = dm(@search)
So, I changed this code to the following:
SELECT * FROM country WHERE dm(name) = dm(@search)
Of course, I changed "@search" to any search query I was looking for, but I got 0 results after every SQL query.
Can anyone explain this problem? Am I missing something important, or am I just misunderstanding the Metaphone algorithm?
Thank!