SQLite Full-Text Search

Aug 21, 2009

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:

CREATE VIRTUAL TABLE TableName
    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:

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.
There is a sam­ple appli­ca­tion to demon­strate full-text search in action:
fts3
Down­load full-text search sam­ple appli­ca­tion.

by bakhtiyor | Categories: Uncategorized | Tagged: , , |

2 Responses so far | Have Your Say!

  1. free tattoo designs
    August 10th, 2010 at 08:35 #

    Very cool web­site, but you must improve your header graphics.

  2. busy Holandia Polska
    August 10th, 2010 at 11:37 #

    I was bored, until i’ve found your site, inter­est­ing posts

Page optimized by WP Minify WordPress Plugin