MySQL全文搜索不匹配

MySQL全文搜索不匹配

本文介绍了MySQL全文搜索不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MySQL表没有返回包含 MATCH(col)AGAINST('')查询的结果。

表格很简单:

  id | url | fullTextIndex 

我的查询是

<$ p $ (7f7f7f807f8080807f8080807f7f7f807c828888808a86967e8b858d7f89838a76829e958f7badb68084a3a38384899077848b877f799f9c85799fa2827d8c8a)FROM图片;<* c $ c> SELECT *,Match(fullTextIndex)AGAINST

最后一列匹配总是0.除了我知道字符串以上是逐字包含在其中一个值中。



注意事项:


  • 该字符串只在该行中(因此它不超过50%的行,所以不应忽略)。 这不是完整值

  • 该列是一个bigText列

  • 当我使用 INSTR 时,我得到值1 (这是正确的)



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

解决方案

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



您可以检查使用 SHOW VARIABLES LIKEft_max_word_len;



的当前值,它在我的服务器上返回84,并且您的字符串是128字符。



建议修复:


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

  2. 重建您的索引建议在MySQL网站上提供: REPAIR TABLE tbl_name QUICK;



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?

解决方案

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;

这篇关于MySQL全文搜索不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 22:41