开发者

Against not returning score

开发者 https://www.devze.com 2023-03-03 04:50 出处:网络
There is something wrong with this query? This one works sometimes and sometimes not. For example with the word \'seven\' it doesn\'t return any score, but i know that it appears on 29 rows at least i

There is something wrong with this query? This one works sometimes and sometimes not. For example with the word 'seven' it doesn't return any score, but i know that it appears on 29 rows at least in the body however it return as score 0.

With other words it work ok but not with this one. Anyone know why or have a different solution to sort it by relevance?

   SELECT *, 
         ( (MATCH(articles.name) AGAINST('seven'))*5 +
           (MATCH(articles.subtitle) AGAINST('seven'))*3 + 
           (MATCH(articles.body) AGAINST('seven'))) AS search_score 
     FROM articles 
LEFT JOIN matches ON articles.match=matches.id 
 ORDER BY search_score DESC

EDIT: I noticed that 'seven' is a stop word. There is other way to do this? stopw开发者_开发技巧ords


Add COALESCE(value,0) around each score.


Problem
If the word is too common, i.e. occurs in 50%+ of the rows, MySQL considers it a STOP-word and will not match against it.
Then there's the stop-word list (which you've already noticed)
See: http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html

Solution
This answer: where to edit mysql fulltext stopword lists?
Tells you how to override/replace the default stop word list.

Here's the link to the MySQL docs page: http://dev.mysql.com/doc/refman/5.5/en/fulltext-fine-tuning.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号