MySQL 全文搜索不匹配
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于索引所考虑的单词长度似乎有一个(可配置的)上限:
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 个字符。
建议的修复:
将此行添加到您的 my.cnf 文件:
ft_max_word_len=128
(或您需要的任何最大长度)按照 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:
Add this line to your my.cnf file:
ft_max_word_len=128
(or whatever max length you need)Rebuild your indexes as advised on the MySQL website:
REPAIR TABLE tbl_name QUICK;