mysql fulltext 不起作用,使用MyISAM表的MySQL(Windows10)FULLTEXT搜索不起作用

I have a problem which I have been able to recreate with two very simple tables. The tables were defined as follows:

create table Temp_Table_MyISAM(

id INT UNSIGNED AUTO_INCREMENT,

code VARCHAR(10) NOT NULL,

name VARCHAR(256) NOT NULL,

PRIMARY KEY (id),

KEY (code),

FULLTEXT (name)

) ENGINE = MYISAM;

create table Temp_Table_InnoDB(

id INT UNSIGNED AUTO_INCREMENT,

code VARCHAR(10) NOT NULL,

name VARCHAR(256) NOT NULL,

PRIMARY KEY (id),

KEY (code),

FULLTEXT (name)

);

Each table has two rows, as can be seen from the result of the following two queries:

select * from Temp_Table_MyISAM;

+----+---------+----------------+

| id | code | name |

+----+---------+----------------+

| 1 | AC-7865 | 38 NORTHRIDGE |

| 2 | DE-3514 | POLARIS VENTRI |

+----+---------+----------------+

select * from Temp_Table_InnoDB;

+----+---------+----------------+

| id | code | name |

+----+---------+----------------+

| 1 | AC-7865 | 38 NORTHRIDGE |

| 2 | DE-3514 | POLARIS VENTRI |

+----+---------+----------------+

When I do a FULLTEXT search on the MyISAM table, I don't get any hits

MariaDB [stackoverflow]> SELECT name, code FROM Temp_Table_MyISAM

WHERE MATCH(name) AGAINST('38');

Empty set (0.00 sec)

MariaDB [stackoverflow]> SELECT name, code FROM Temp_Table_MyISAM

WHERE MATCH(name) AGAINST('POLARIS');

Empty set (0.00 sec)

When I do a FULLTEXT search on the InnoDB table, I get a hit only when the pattern to be matched does not start with a numeric value

MariaDB [stackoverflow]> SELECT name, code FROM Temp_Table_InnoDB

WHERE MATCH(name) AGAINST('38');

Empty set (0.00 sec)

MariaDB [stackoverflow]> SELECT name, code FROM Temp_Table_InnoDB

WHERE MATCH(name) AGAINST('POLARIS');

+----------------+---------+

| name | code |

+----------------+---------+

| POLARIS VENTRI | DE-3514 |

+----------------+---------+

Any insight would be appreciated.

解决方案

There are 3 rules to watch out for in MyISAM's FULLTEXT:

Text words shorter than ft_min_word_len (default 4 characters) will not be indexed. ("38")

Search words that show up in more 50% or more of the rows, will be ignored. ("Polaris")

"Stop words" in the text are not indexed. ("the", "and", ...)

Since InnoDB now supports FULLTEXT, you should move to that engine. (And the rules are different there.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值