现在的位置: 首页 > 综合 > 正文

MySQL全文检索学习!

2017年11月24日 ⁄ 综合 ⁄ 共 1040字 ⁄ 字号 评论关闭

-- 需要在my.cnf里面设置一个参数
# full text param init
ft_min_word_len=1

use test;
drop table if exists tnew;
CREATE TABLE `tnew` (
`id`  int NOT NULL primary key ,
`content`  longtext  ,
FULLTEXT INDEX `content` (`content`)
)
ENGINE=MyISAM
CHECKSUM=0
DELAY_KEY_WRITE=0
;

insert into test.tnew
select 1,'DBMS stands for DataBase ...';
insert into test.tnew
select 2,'After you went through a ...';
insert into test.tnew
select 3,'In this tutorial we will show ...';
insert into test.tnew
select 4,'In the following database comparison ...';
insert into test.tnew
select 5,'假如你将一个编入索引的列派给BINARY, MySQL 将不能有效使用这个索引。..';

insert into test.tnew
select 6,'这是一种简单的方式来促使逐字节而不是逐字符的进行列比较。这使得比较区分大小写,即使该列不被定义为 BINARY或 BLOB。BINARY也会产生结尾空白,从而更加显眼..';
insert into test.tnew
select 7,'BINARY影响整个比较;它可以在任何操作数前被给定,而产生相同的结果。';
insert into test.tnew
select 8,'若要使用一个不同的字符集, 替换其在上述语句中的latin1名.';
insert into test.tnew
select 9,'索引';
insert into test.tnew
select 10,'索引集合';
set names 'utf8';

Select * from tnew where MATCH content AGAINST ('mysql');
-- 有记录
Select * from tnew where MATCH content AGAINST ('索引');
-- 只有一条记录   9,'索引'; 
-- 可见mysql的全文索引对中文不支持?google结果,都是在php层面解决lamp中文全文检索的问题,不是在数据库层面解决的!
-- 谁如果知道的,留言下

抱歉!评论已关闭.