全文检索技术 sql server
程序员文章站
2022-08-04 16:49:57
在未做全文检索以前,个人主页只能对fs_title(文章标题)字段进行模糊查询(like '%*%'),如果对内容进行模糊查询,速度极慢,有时还可能报错,今天终于...
在未做全文检索以前,个人主页只能对fs_title(文章标题)字段进行模糊查询(like '%*%'),如果对内容进行模糊查询,速度极慢,有时还可能报错,今天终于有空了,把这个查询做好了,经过测
试,检索一万条纪录不到两秒时间。enjoy~~
use luanluandb
exec sp_fulltext_database 'enable'
exec sp_fulltext_catalog 'artilefulltext', 'create', 'e:\searchpage'
exec sp_fulltext_table 'tarticle', 'create', 'artilefulltext', 'pk_tarticle'
exec sp_fulltext_column 'tarticle', 'fs_title', 'add'
exec sp_fulltext_column 'tarticle', 'fs_content', 'add'
exec sp_fulltext_table 'tarticle', 'start_full'
测试代码:select * from tarticle where contains(*,'"&key&"') and fi_isshow='1' order by fi_id desc
试,检索一万条纪录不到两秒时间。enjoy~~
复制代码 代码如下:
use luanluandb
exec sp_fulltext_database 'enable'
exec sp_fulltext_catalog 'artilefulltext', 'create', 'e:\searchpage'
exec sp_fulltext_table 'tarticle', 'create', 'artilefulltext', 'pk_tarticle'
exec sp_fulltext_column 'tarticle', 'fs_title', 'add'
exec sp_fulltext_column 'tarticle', 'fs_content', 'add'
exec sp_fulltext_table 'tarticle', 'start_full'
测试代码:select * from tarticle where contains(*,'"&key&"') and fi_isshow='1' order by fi_id desc