Searching similar words in Mysql with android app

Viewed 53

I have an android application which has search bar for user looks for products. And all informations are stored in Mysql.

When a user search for a product, the results are exactly what user write, but I want to results contain also similar words with considering of may be user wrote incorrect.

I'm using this SQL statement:

SELECT *, MATCH(product_name) AGAINST('galaxy' IN NATURAL LANGUAGE MODE) as score FROM product WHERE MATCH(product_name) AGAINST('galaxy' IN NATURAL LANGUAGE MODE) ORDER BY score

Assume that my table something like that

id product_name
1 Galaxy S20
2 Galaxy S10
3 Playstation

So if the user enters 'galaxy', the result will be Galaxy S20 and Galaxy S10. It's ok. But If user enters 'galaxt' by mistake, then result will be null. For this situation, I want to detect user's entering and list Galaxy S20 and Galaxy S10 because of user made mistake.

I tried SOUNDEX too, but it didn't what I want.

Someone say could be Levenshtein Distance, but I'm not sure.

So how can I list with similar words? Is it about android side or sql statement?

0 Answers
Related