我正在尝试使用 mysql 查找与给定名称最接近的匹配项。前两个结果的得分相同,但看着它我宁愿得到第二个,因为它几乎符合这个名字。
SELECT ID, name, MATCH (`name`)
AGAINST ('Superocean Héritage 42mm' IN BOOLEAN MODE) as `score`
FROM cat_names cs
WHERE MATCH (`name`) AGAINST ('Superocean Héritage 42mm' IN BOOLEAN MODE)
ORDER BY `score` DESC
结果:
Superocean Héritage 6.3744072914123535
Superocean Héritage 42 6.3744072914123535
Superocean Héritage 46 6.3744072914123535
有没有办法调整查询以正确检索第二个结果?
此外,全文搜索返回精确匹配的低质量分数:
Big Bang Aero Bang
9.445959091186523
Big Bang 44 mm
6.32852840423584
Big Bang Caviar
6.32852840423584
Big Bang Jeans
6.32852840423584
Big Bang Meca-10
6.32852840423584
Big Bang Sang Bleu
6.32852840423584
Big Bang Unico
6.32852840423584
Spirit of Big Bang
6.32852840423584
Big Bang 41 mm
6.32852840423584
Big Bang Broderie
6.32852840423584
Big Bang Ferrari
6.32852840423584
Big Bang King
6.32852840423584
Big Bang Pop Art
6.32852840423584
Big Bang Tutti Frutti
6.32852840423584
Big Bang
6.32852840423584
完全匹配的分数最低。
啊,你想要更高的精确匹配分数?代替
做
=
测试将针对1
完全匹配,否则0
。因此,实际上,它否决了任何score
回报。(其他表达方式包括
IF
orCASE
)。