我使用布尔全文搜索从数据库列中搜索单词。我想获得与我的记录完全匹配的记录,还包括通配符搜索。我得到了正确的结果,但我想首先通过完全匹配来设置该结果的顺序。有没有可能的方法来实现这一目标?
我还想对每个单词进行搜索并按相关性获取记录。
我试过使用以下查询,但它不起作用,因为它给了我错误的记录排名。
SELECT
id,
search_tags,
MATCH(search_tags) AGAINST(REPLACE(concat("'car'"," ")," ","* ") IN BOOLEAN MODE) AS relevance_rank
FROM
images
WHERE
MATCH(search_tags) AGAINST(REPLACE(concat("'car'"," ")," ","* ") IN BOOLEAN MODE)
ORDER BY relevance_rank DESC;
我希望查询的输出是
id search_tag relevance_rank
11 car,cards,food,code 2.1669161319732666
12 car,water,sky 2.1669161319732665
13 carrier,food,drink 2.1669161319732664
,但实际输出就像
id search_tag relevance_rank1
11 carrier,food,drink 2.1669161319732666
12 car,cards,food,code 2.1669161319732666
13 car,water,sky 2.1669161319732666
叮当猫咪
慕盖茨4494581