Mysql基础第二十一天,全文本搜索

阅读 24

2022-10-14


理解全文本搜索

create table fs(id int not null primary key,c text,fulltext(c) engine = MyISAM;  // fulltext全文本搜索

使用全文本搜索

select note_text from productnotes where match(note_text) against('rabbit');

启用全文本搜索支持

select note_text from productnotes where match(note_text) against('rabbit');

进行全文本搜索

select note_text from productnotes where match(note_text) against('rabbit');

使用查询扩展

select note_text from productnotes where match(note_text) against('anvils' with query expansior);

布尔文本搜索

select note_text from productnotes where match(note_text) against('heavy -rope' in boolean mode);
select note_text from productnotes where match(note_text) against('+ rabit +bait' in boolean mode); // '+rabit +bait' 必须同时含有
select note_text from productnotes where match(note_text) against('+ rabit +bait' in boolean mode); // 'rabit +bait' 必须同时含有
select note_text from productnotes where match(note_text) against("rabit bait" in boolean mode); // "rabit bait" 必须同时含有

全文本搜索的使用说明

短词被忽略(<=3);
内建非用词列表;
50%的出现频率,作为非用词(不用于bool搜索);
若表中行数少于3,将不返回结果;
忽略单引号;
不是所有的引擎都支持全文本搜索。


精彩评论(0)

0 0 举报