MySQL – Efficient search with partial word match and relevancy score (FULLTEXT)

The new InnoDB full-text search feature in MySQL 5.6 helps in this case.
I use the following query:

SELECT MATCH(column) AGAINST('(word1* word2*) ("word1 word1")' IN BOOLEAN MODE) score, id, column 
FROM table
having score>0
ORDER BY score 
DESC limit 10;

where ( ) groups words into a subexpression. The first group has like word% meaning; the second looks for exact phrase. The score is returned as float.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)