问题描述
我正在使用以下代码作为示例:
I am using the below code for example:
SELECT *, (MATCH (`wm`, `locn`, `gns`) AGAINST('foot locker')) AS score FROM `example_table` WHERE MATCH (`wm`, `locn`, `gns`) AGAINST('foot locker')) order by score DESC;
但是,即使wm
列中存在完全匹配项,但直到第8个结果时,都不会出现完全匹配项.前面的单词也都有短语,但后面还有一些文字.我检查了locn
,gns
字段,以了解它们之间的比较,没有什么能真正使他人得分更高的突出之处.
However even though EXACT matches exist in the wm
column, the EXACT match doesn't appear untiil the 8th result. The ones ahead of it all have the phrase too, but also some following text. I checked the locn
, gns
fields to see how they compared and nothing really stands out that should make the others score higher.
我阅读了有关使用BOOLEAN MODE
的内容,但是在那儿读到的东西似乎都不能满足我的需求.
I did some reading about using BOOLEAN MODE
but nothing I read there seemed like it would help my needs.
推荐答案
好吧,如果这可以帮助其他人实现此目标,我就可以做到:
Ok, if this helps anyone else I was able to achieve what I wanted by doing this:
SELECT *,
CASE WHEN wm = 'foot locker' THEN 1 ELSE 0 END AS score,
MATCH (`wm`, `locn`, `gns`) AGAINST('foot locker') AS score2
FROM
`example_table`
WHERE
MATCH (`wm`, `locn`, `gns`) AGAINST('foot locker'))
ORDER BY
score DESC, score2 DESC;
这篇关于首先从全文搜索中获取精确匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!