0

如何按相关性制作php全文搜索顺序?

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

我想设置相关性,首先应该匹配col1, col2然后匹配col3,如果匹配完成更多的单词col1, col2,然后交col3

也许我应该设置一个百分比,比如col1, col266% 的相关性和col334% 的相关性......

4

1 回答 1

1

你可以尝试这样的事情:

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
于 2011-08-29T07:18:52.593 回答