PHP mysql全文搜索顺序的相关性



如何使php全文搜索顺序的相关性?

SELECT * FROM table
WHERE MATCH (col1,col2,col3) 
AGAINST ('+$boolean' IN BOOLEAN MODE)
Order By relevance

我想设置相关性,首先应该匹配col1, col2,然后匹配col3,如果col1, col2完成匹配,则转到col3

也许我应该设置一个百分比,比如col1, col2的相关性为66%,col3的相关性为34%…

您可以尝试这样做:

SELECT *, (MATCH(col1, col2) AGAINST('+$boolean' IN BOOLEAN MODE) * 0.66 + MATCH(col3) AGAINST('+$boolean' IN BOOLEAN MODE) * 0.34) AS relevance
FROM table
WHERE MATCH(col1, col2, col3) AGAINST ('+$boolean' IN BOOLEAN MODE)
ORDER BY relevance DESC

相关内容

  • 没有找到相关文章

最新更新