sql MyISAM的全文搜索FULLText

创建

create table products (
    id int NOT NULL AUTO_INCREMENT,
    prod_id char(10) NOT NULL,
    content text NULL,
    PRIMARY KEY(id),
    FULLTEXT(content)
) ENGINE = MyISAM;

匹配使用

select content
from products
where Match(content) Against('搜索词');
select id, Match(content) Against('搜索词') AS rank
from products;
//搜索出来的是包含了'搜索词'的等级值得 ,靠前越多,没有为0

扩展搜索

select content
from products
where Match(content) Against('搜索词' WITH QUERY EXPANSION);
//搜索匹配的,搜索匹配到的数据的相关词的其他数据行等等 按等级值排序

布尔文本搜索

select content
from products
where Match(content) Against('搜索词' IN BOOLEAN MODE);
select content
from products
where Match(content) Against('搜索词 -搜索词二*' IN BOOLEAN MODE);
//-表示排除后面的 *通用匹配

clipboard.png
clipboard.png
clipboard.png

mysql5.6版本innodb也开始支持fulltext

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值