注册 登录
编程论坛 MySQL论坛

MySQL用全文本搜索,表中有数据为什么查询结果是空集合

花脸 发布于 2019-01-31 12:24, 2477 次点击
创建表
程序代码:
create table text(
    -> id int not null auto_increment,
    -> texts text null,
    -> primary key(id),
    -> fulltext(texts))engine=myisam;
跟新原有的数据
update text set texts='happer new year!';
查看表中的数据
程序代码:
select * from text;
+----+------------------+
| id | texts            |
+----+------------------+
|  1 | happer new year! |
|  2 | happer new year! |
|  3 | happer new year! |
+----+------------------+
j进行全文本搜索
select texts from text where match(texts) against('new');
Empty set (0.00 sec)

3 回复
#2
阿ki2019-02-12 14:44
回复 楼主 花脸
因为默认的最小分词长度是4,new长度只有3,所以被忽略
show variables like '%ft%';
可以看到ft_min_word_len=4
可先停止MySQL,在my.ini配置文件中增加或修改 ft_min_word_len = 3,再重启MySQL
#3
花脸2019-02-14 14:57
回复 2楼 阿ki
好的,谢谢
#4
Binhun2019-05-31 19:33
1