从首先返回的全文搜索中获取精确匹配?

发布于 2024-12-01 21:18:44 字数 441 浏览 1 评论 0原文

例如,我使用下面的代码:

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 个结果才会出现。前面的也都有这个短语,但也有一些后面的文字。我检查了 locngns 字段以了解它们的比较情况,但没有什么真正突出的地方可以让其他人得分更高。

我读了一些关于使用 BOOLEAN MODE 的文章,但我读到的内容似乎都无法满足我的需求。

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;

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.

I did some reading about using BOOLEAN MODE but nothing I read there seemed like it would help my needs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2024-12-08 21:18:44

好的,如果这对其他人有帮助,我就可以通过这样做实现我想要的目标:

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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文