MySQL MATCH AGAINST 功能

发布于 2024-09-04 04:38:48 字数 296 浏览 8 评论 0原文

目前我有以下查询...

SELECT id, 
       LOWER(title) as title, 
       LOWER(sub_title) as sub_title
  FROM ebay_archive_listing
 WHERE MATCH(title, sub_title) AGAINST ("key" IN BOOLEAN MODE)

但是它没有找到 title 包含单词“key”的行。 “key”是根据一组关键字动态生成的,因此有时它包含+和-符号。

Currently I have the following query...

SELECT id, 
       LOWER(title) as title, 
       LOWER(sub_title) as sub_title
  FROM ebay_archive_listing
 WHERE MATCH(title, sub_title) AGAINST ("key" IN BOOLEAN MODE)

However it is not finding rows where the title contains the word "key". "key" is generated dynamically based on a set of keywords, so sometimes it contains + and - symbols.

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

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

发布评论

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

评论(1

瑕疵 2024-09-11 04:38:48

MySQL 的默认全文索引设置不会索引或匹配任何少于四个字母的单词。

如果您有一个短语完全由少于四个字母的单词组成,例如 key,则必须手动回退到未索引的 LIKE 搜索。

您可以通过降低ft_min_word_len来更改此行为设置。您可能还想在使用时更改或禁用“停用词”列表(也未编入索引),因为默认列表是残酷且奇怪的。

MySQL's default fulltext indexing settings won't index or match any word of fewer than four letters.

If you have a phrase made entirely of words of fewer than four letters like key you have to manually fall back to an unindexed LIKE search instead.

You can change this behaviour by lowering the ft_min_word_len setting. You might also want to change or disable the list of ‘stopwords’ (which are also not indexed) whilst you're at it, as the default list is brutal and bizarre.

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