Answer the question
In order to leave comments, you need to log in
How to make a search with the ability to search by transliteration?
Good day. For example, there is a peoples table with fields id, name, ...
Tell me, how can I do a search on the "name" field, which transliteration understands? Well, for example, as in a contact, I start typing "anna iwano" in the search field, and the search results show:
Anna Ivanova
Anna Ivanova
Anna Iwanowa
Thank you in advance for your answer.
Answer the question
In order to leave comments, you need to log in
Make a transliteration in the application code, and use the result to search the database.
Maybe write a sql function? After googling I found an example:
CREATE FUNCTION `translit`(`_txt` TEXT)
RETURNS text
BEGIN
SET _txt=REPLACE(REPLACE(REPLACE(_txt /* И так далее, для каждого символа */,'В','V'),'Б','B'),'А','A');
RETURN _txt;
END
Depending on the use cases, we apply the following options alternately until success or in parallel:
1. We search as is
2. We try to determine the encoding and language, normalize and search again (we convert the transliteration w and v-> to, we forgot to switch the layout bdfyjd -> Ivanova)
3. We are looking for a fuzzy match (inanova)
Also, do not forget to describe the ranking rules (ivan is all "ivans" or all ivan * )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question