We're using an FAQ table below, to demonstrate how to return a result set that includes the keyword relevance as a percentage of the maximum relevance.

SELECT f.faq_question, f.faq_answer,  ROUND(((MATCH(faq_question, faq_answer) AGAINST ('mykeyword')) / scores.max_score) * 100) as relevance
FROM faq f,
     (SELECT MAX(MATCH(faq_question, faq_answer) AGAINST('mykeyword')) as max_score FROM faq LIMIT 1) scores
HAVING relevance > 0
ORDER BY relevance DESC

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *