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

SQLite的全文检索

2013年09月09日 ⁄ 综合 ⁄ 共 390字 ⁄ 字号 评论关闭

如果需要在其中做全文检索的话,也是可以的。因为sqlite中支持fts表

这里的FTS3其实是sqlite的一个扩展模块,是虚拟表模块,允许用户去实现全文检索。

下面是一个简单的例子:

create virtual table test using fts3(content text);     

表建立以后sqlite还会自动创建3个表:test_content、test_segdir、test_segments。

/* 关键词 */ 
select count(*) from test where content match 'farmer';

/* 支持通配符 */ 
select count(*) from test where content match 'far*';

/* 支持匹配哪一行 */
select * from test where content match 'content:1231*';

还有什么用法可以以后再加 感觉应该会用到的,做个记号。

抱歉!评论已关闭.