我正在开发一个搜索引擎,我使用以下代码进行查询:
SELECT * FROM books WHERE MATCH(titulo, description) AGAINST ('mark the android' IN BOOLEAN MODE)
我得到了很多结果,但我希望在不太一致的结果之前得到最好的结果。
我该如何做到这一点?
由于
答案 0 :(得分:0)
您要执行的操作是删除IN BOOLEAN MODE
并按MATCH ... AGAINST ...
排序,因为它会返回表示相关性的数字。
SELECT * FROM books
WHERE MATCH(titulo, description) AGAINST ('mark the android')
ORDER BY MATCH(titulo, description) AGAINST ('mark the android') DESC
如果您想查看数字以了解数字是什么,您只需选择它就像这样
SELECT *,MATCH(titulo, description) AGAINST ('mark the android') as relevancy FROM books
WHERE MATCH(titulo, description) AGAINST ('mark the android')
ORDER BY MATCH(titulo, description) AGAINST ('mark the android') DESC