how to perform full text search using sqlite fts3
I have compiled the fts3 module for sqlite3.6.2. How to build the virtual table and perform search on some field of existent tables (like content:string in tweets)? Does ft3 support fuzzy search? (I checked the documentation but still r开发者_Go百科emained horribly confused...).
You can do something as simple as this to search on 2 fields. You have to use unions.
string createSql = "CREATE VIRTUAL TABLE TweetFts USING FTS3(TweetId, Title, Description)";
string insertSql = "INSERT INTO TweetFts (TweetId, Title, Description)
SELECT TweetId, Title, Description FROM Tweet";
string sql = @"select TweetId from TweetFts where Title match '" + allWords + "'";
sql += " union ";
sql += @"select TweetId from TweetFts where Description match '" + allWords + "'";
sql += " union ";
sql += @"select TweetId from TweetFts where Title match '""" + exactMatch + @"""'";
sql += " union ";
sql += @"select TweetId from TweetFts where Description match '""" + exactMatch + @"""'";
Run this query and you have a list of Tweet that match.
I don't see anything fuzzy other than the prefix search using *.
There is a soundex function.
精彩评论