I want to use FTS in my iOS project. Through some answers to questions here on SO (like this) and other sources (like this), i understood that i will have to roll out my own built of sqlite3 on iOS, thus replacing the dependency to default libsqlite3.dylib.
But when i directly run the query (in a new project, with just the standard 'libsqlite3.dylib' linked and no custom sqlite build) :
"SELECT rowid FROM pages WHERE textcontent MATCH 'jim';"
on a table 'pages' created by using query :
"CREATE VIRTUAL TABLE pages USING fts3(textcontent TEXT)",
I dont get any errors, instead, i get the correct result (rowid of the rows in which the word 'jim' exists) as if the FTS is enabled by defalt in the built-in iOS sqlite library .
So, is this the case? Has apple now enabled FTS in the standard/built-in sqlite library? Or there is something that i am missing here?
Thanks.
PS. I am using FMDB in my project as an sqlite wrapper and here is the code that i use to test the above.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *dbDocumentsPath = [documentsDir stringByAppendingPathComponent:@"1.db"];
FMDatabase *db = [FMDatabase databaseWithPath:dbDocumentsPath];
if (![db open])
NSLog(@"Could not open db.");
if([db executeUpdate:@"CREATE VIRTUAL TABLE pages USING fts3(textcontent TEXT)"])
NSLog(@"Virtual Table Created");
if([db executeUpdate:@"INSERT INTO pages(textcontent) VALUES ('Jack')"])
NSLog(@"First Insert Done");
if([db executeUpdate:@"INSERT INTO pages(textcontent) VALUES ('jim is jam')"])
NSLog(@"Second Insert Done");
FMResultSet* resultSet1 = [db executeQuery:@"SELECT rowid FROM pages WHERE textcontent MATCH 'jim';"];
while([resultSet1 next])
NSLog(@"%@",[resultSet1 objectForColumnName:@"rowid"]);
This guy confirms your findings by asserting in his second blog update that FTS3 is included in iOS 5's SQLite library. (I have also tested this and came to the same conclusion.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With