ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Android 全文 检索 Full Text Search 资料

Android 全文 检索 Full Text Search 资料

原创 Linux操作系统 作者:v_gyc 时间:2009-12-18 14:51:40 0 删除 编辑
用户反映app文本查询很慢

确实做程序的时候 也没多想 偷懒啦

文本查询 就一行接一行 做 indexOf 查询 比较慢。


不要自己开发全文检索啦(嘿嘿 不会) 

网上找了android全文检索的资料

主要是SQLite和android 支持

http://www.v2ex.com/2008/11/22/full-text-search/

http://bakhtiyor.com/2009/08/sqlite-full-text-search/

SQLite con­tains full-text search mod­ule called FTS3, using this mod­ule you can eas­ily add fast full text search to an Android appli­ca­tion.
First you need to cre­ate vir­tual table:


1.CREATE VIRTUAL TABLE TableName
2.    USING FTS3(ColOne TEXT, ColTwo DATETIME)

Your table must con­tains at least 1 TEXT field.
The FTS3 vir­tual table acts like a reg­u­lar table, but you need to man­u­ally main­tain the indexes to keep ref­er­en­tial integrity — you should UPDATE the FTS3 table from time to time.
The full-text query in SQLite looks like this:


1.SELECT * FROM TableName WHERE ColOne MATCH 'search phrase'
Make sure you use MATCH instead of equals or LIKE to scan a TEXT col­umn in a vir­tual table.

回头修改 哈哈

PS 某牛 发表的回复 中文支持不是太好
FTS3 needs to be hacked to support splitting chinese texts.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/86970/viewspace-622856/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: o come o come emmanuel
请登录后发表评论 登录
全部评论

注册时间:2008-08-02

  • 博文量
    10
  • 访问量
    37766