Suggestion For Finding Similar Rows In Mysql
i want select similar rows accourding to row's title columun. Title columun has mostly have 5 or 6 six keywo开发者_高级运维rds. Which algorithm do you recommend ? Soundex Maybe ?
P.S: Title columun has unicode chracters like Ç, Ö, Ş...
My question's answer mysql full text search. Also it supports unicode.
SELECT *, match(project_title) against('sample project 55') as similarity
FROM projects
WHERE status IN(1, 2, 3, 4, 5, 6) AND id != ? AND match('sample project 55') against(?)
ORDER BY similarity DESC
If you mean similar in spelling and pronunciation, I'd look into using the SOUNDEX
function.
Honestly, I'd create a table for keywords(id, external_id, keyword)
, and then I would join the table against itself, order by how many matches there are, and then grab the rows back out.
If you're matching against a single row, you can select only that one, for much better efficiency with the join.
This could be combined with SOUNDEX to match together things that are close
精彩评论