SyntaxStudy
Sign Up
MySQL Tuning Relevance Scores
MySQL Advanced 4 min read

Tuning Relevance Scores

Tuning Relevance

Boost relevance for title matches by weighting scores manually. You cannot configure TF-IDF weights directly, but you can combine scores arithmetically.

Example
SELECT id, title,
  (MATCH(title) AGAINST('mysql') * 3 +
   MATCH(body)  AGAINST('mysql'))  AS weighted_score
FROM articles
WHERE MATCH(title, body) AGAINST('mysql')
ORDER BY weighted_score DESC;
Pro Tip

Use separate single-column indexes if you want to weight columns differently.