MySQL 全文搜索不匹配

发布于 2024-12-20 09:05:53 字数 602 浏览 2 评论 0原文

我的 MySQL 表未通过 MATCH (col) AGAINST ('') 查询返回结果。

该表很简单:

id | url | fullTextIndex

我的查询是

SELECT *, Match(fullTextIndex) AGAINST ("7f7f7f807f8080807f8080807f7f7f807c828888808a86967e8b858d7f89838a76829e958f7badb68084a3a38384899077848b877f799f9c85799fa2827d8c8a ") FROM Pictures;

最后一列,即匹配项,始终为 0。除了,我知道上面的字符串逐字包含在其中一个值中。

需要注意的事项:

  • 该字符串仅在该行中(因此它不在超过 50% 的行中,因此不应忽略它)。
  • 这不是完整值
  • 该列是一个 bigText 列
  • 当我使用 INSTR 时,我得到值 1 (这是正确的)

有什么想法为什么这个查询可能不起作用?

My MySQL table is not returning results with a MATCH (col) AGAINST ('') query.

The table is simple:

id | url | fullTextIndex

And my query is

SELECT *, Match(fullTextIndex) AGAINST ("7f7f7f807f8080807f8080807f7f7f807c828888808a86967e8b858d7f89838a76829e958f7badb68084a3a38384899077848b877f799f9c85799fa2827d8c8a ") FROM Pictures;

The last column, the match, is always 0. Except, I know for a fact that the string above is contained, verbatim, in one of the values.

Things to note:

  • The string is only in that row (so it is not in more than 50% of rows, so it shouldn't be ignored).
  • This is not the Full value
  • The column is a bigText column
  • When I use INSTR, I get the value 1 (which is correct)

Any ideas why this query might not be working?

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

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

发布评论

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

评论(1

单调的奢华 2024-12-27 09:05:53

对于索引所考虑的单词长度似乎有一个(可配置的)上限:

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_ft_max_word_len

您可以使用 SHOW VARIABLES LIKE "ft_max_word_len"; 检查当前值,

它在我的服务器上返回 84,而您的字符串长度为 128 个字符。

建议的修复:

  1. 将此行添加到您的 my.cnf 文件:ft_max_word_len=128(或您需要的任何最大长度)

  2. 按照 MySQL 网站上的建议重建索引:REPAIR TABLE tbl_name QUICK;

There seems to be a (configurable) upper limitation on the length of the words considered for indexation:

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_ft_max_word_len

You can check the current value with SHOW VARIABLES LIKE "ft_max_word_len";

It returns 84 on my server, and your string is 128 chars long.

Suggested fix:

  1. Add this line to your my.cnf file: ft_max_word_len=128 (or whatever max length you need)

  2. Rebuild your indexes as advised on the MySQL website: REPAIR TABLE tbl_name QUICK;

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