match() against() 不起作用,但就像 '%$s%'做

发布于 2024-11-16 07:18:18 字数 375 浏览 0 评论 0原文

我的表中有一个全文字段。其中一行是:

"this is the dog that ran over there"

我有以下 mysql 语句:

SELECT * 
  FROM `table` 
 WHERE MATCH (column) AGAINST ('dog that ran')

...返回 0 条记录

SELECT * 
  FROM `table` 
 WHERE `column` LIKE '%dog that ran%'

...返回 1 条记录

为什么有差异?他们都应该返回 1 条记录,对吗?

I have a fulltext field in my table. One of the rows is:

"this is the dog that ran over there"

I have the following mysql statements:

SELECT * 
  FROM `table` 
 WHERE MATCH (column) AGAINST ('dog that ran')

...returns 0 records

SELECT * 
  FROM `table` 
 WHERE `column` LIKE '%dog that ran%'

...returns 1 record

Why the difference? They should both return 1 record, right?

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

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

发布评论

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

评论(1

青春如此纠结 2024-11-23 07:18:18

从我的对另一个问题的回答

全文搜索有一些奇怪的怪癖。

例如, this 的最后段落中描述的行为页面可能是您的问题的原因:

....例如,尽管前面显示的文章表的每一行中都存在“MySQL”一词,但对该词的搜索不会产生任何结果:

mysql>从文章中选择 *
    -> WHERE MATCH (标题,正文) AGAINST ('MySQL');
 空集(0.00 秒)

搜索结果为空,因为至少 50% 的行中出现“MySQL”一词。因此,它实际上被视为停用词。对于大型数据集,这是最理想的行为:自然语言查询不应从 1GB 表中每隔一行返回一次。对于小数据集,可能不太理想。

这里的答案是添加更多行,或使用布尔搜索。

From my answer to another question:

Fulltext search has some bizarre quirks.

For example, the behaviour described in the last paragraphs of this page could be the reason for your problem:

.... for example, although the word “MySQL” is present in every row of the articles table shown earlier, a search for the word produces no results:

mysql> SELECT * FROM articles
    -> WHERE MATCH (title,body) AGAINST ('MySQL');
 Empty set (0.00 sec)

The search result is empty because the word “MySQL” is present in at least 50% of the rows. As such, it is effectively treated as a stopword. For large data sets, this is the most desirable behavior: A natural language query should not return every second row from a 1GB table. For small data sets, it may be less desirable.

The answer here would be to add more rows, or use boolean search.

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