我正在从全文mysql dbTable中选择文本,命中按相关性排序,再乘以客户端提供的权重。查询工作正常,但我想作为一个 查询的“AS score”子句将实际加权相关性分数返回给客户端(通过php)。我试过到处插入AS子句,但没有成功。 建议? 谢谢
$sql1="SELECT * FROM $dbTable
WHERE MATCH (data) AGAINST ('".$key_word_1."')
OR MATCH (data) AGAINST('".$key_word_2."')
ORDER BY (MATCH (data) AGAINST('".$key_word_1."') * $weight_1) + (MATCH (data) AGAINST('".$key_word_2."') * $weight_2) DESC
LIMIT 200";
答案 0 :(得分:1)
你可以这样做:
SELECT * , (MATCH (data) AGAINST('".$key_word_1."') * $weight_1) + (MATCH (data) AGAINST('".$key_word_2."') * $weight_2) AS score
....
ORDER BY score DESC