How can I manipulate MySQL fulltext search relevance to make one field more 'valuable' than another?

前端 未结 9 1736
灰色年华
灰色年华 2020-11-28 02:55

Suppose I have two columns, keywords and content. I have a fulltext index across both. I want a row with foo in the keywords to have more relevance than a row with foo in th

9条回答
  •  一向
    一向 (楼主)
    2020-11-28 03:34

    As far as I know, this isn't supported with MySQL fulltext search, but you can achieve the effect by somehow repeating that word several times in the keyword field. Instead of having keywords "foo bar", have "foo bar foo bar foo bar", that way both foo and bar are equally important within the keywords column, and since they appear several times they become more relevant to mysql.

    We use this on our site and it works.

提交回复
热议问题