MySQL 全文搜索不适用于某些单词,例如“house”;

发布于 2024-10-10 07:08:02 字数 236 浏览 0 评论 0原文

我已经在 3 个字段中的一小部分记录上设置了全文索引(也尝试了 3 个字段的组合,并得到了相同的结果),有些单词返回结果很好,但某些单词如“house”和“澳大利亚”不这样做(有趣的是,“澳大利亚”和“家乡”这样做)。

这似乎是奇怪的行为。如果我添加“WITH QUERY EXPANSION”,我会得到结果,但它们现在不是最相关的。

有人知道这是为什么吗?否则,我将不得不求助于使用“LIKE”搜索,并且我更愿意包含相关性。

I've setup a full text index on a small selection of records across 3 fields (tried a combination of the 3 as well and had the same result), and some words return results fine, but certain ones such as 'house' and 'australia' don't (interestingly, 'australian' and 'home' do).

It seems like odd behaviour. If I add "WITH QUERY EXPANSION" I get results, but they aren't the most relevant now.

Anyone got any idea why this is? Otherwise I'm going to have to resort to using LIKE searches, and I'd prefer to have relevancy included.

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

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

发布评论

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

评论(1

只等公子 2024-10-17 07:08:02

可能有以下几个原因:

  • MySQL 有一个默认的“停用词”列表,未包含在全文搜索中 - http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html 。 “house”和“australia”似乎不在该列表中,但您搜索的其他单词可能会受到它的影响。
  • 数据库中出现在超过 50% 的行中或长度为 3 个字母或更少的任何单词也被视为停用词。如果您只是在只有几行的表上测试全文搜索,则 50% 的事情特别容易被发现。

如果您在 Google 中搜索“mysql stop Words”,您会发现更多关于它,因为这是让很多人感到困惑的事情之一。

It could be a couple of things:

  • MySQL has a default list of 'stop words' that aren't included in a full text search - http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html . 'house' and 'australia' don't seem to be in that list, but other words you search for might be affected by it.
  • Any word that appears in over 50% of the rows or is 3 letters or in less in length in the database is also considered a stop word. The 50% thing is particularly easy to be caught out by if you're just testing the full text search out on a table with only a few rows in.

If you search Google for "mysql stop words" you'll find a lot more about it, as it's one of those things that catches a lot of people out.

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