views:

99

answers:

4

Current database have 200 thousand record. I want to make iPad application , can I run 200 thousand record with sqlite ? I don't want to use sqlite because searching is too slow over 32000. Any search engine like lucene for iPhone SDK ? if we can run lucene in iPad that will be awesome because current project is base on lucene. Can you give me a suggestion ?

Thank You

A: 

I understand Lucene is written in Java - that'd mean you can't use it on the iPad.

Have you actually created indexes in your Sqlite database? In my experience Sqlite is really quite fast. If Core Data is too slow you could also try using the native C API.

Thomas Müller
yes. I know. Lucene can't run on iPad. I will try with sqlite or if I'm satisfy for speed, we should write native C API.
saturngod
+2  A: 

I suggest to build you own fulltext index. I don't think SQLite on the iPhone supports triggers, but you can still use a similar algorithm than the H2 fulltext search implementation. The idea is to split the text data into words, and then add those to an table that is indexed on the word. The algorithm for building the index is relatively simple. The native H2 fulltext search doesn't have all the features the Lucene fulltext search has, but it's much simpler to implement.

Thomas Mueller
I like this idea. Its actually pretty simple and I did this not so long ago.
John Ballinger
+1  A: 

Hi,

I recently built an iPhone app with 86,000 rows and SQLite.

At first I didn't index my serach row and searches were taking about 1 second to execut on an iPod touch 2nd generation. Once I added my indexes searching was instant.

To be honest you might be able to get away with "like" queries on the field you are looking for? It might actually be good enough. I think you will find that once you add indexes to your data, the database is really going to grow in size and could make you app pretty big and putting a full blown search engine in there could be a real pain.

Here is some code to quickly do some tests for a SQLite database.

http://www.rvaidya.com/blog/iphone/2009/02/14/wrapper-classes-for-using-sqlite-on-iphonecocoa/

SQLiteResult *result = [SQLite query:@"SELECT * from test;"];
NSArray *row = [result.rows objectAtIndex:0];
NSString *firstValue = [row objectAtIndex:0];
John Ballinger
If you use LIKE 'text%' then it's OK (SQLite can use an index in that case), but I would avoid using LIKE '%text%'. This will result in a table scan, and a table scan on 200'000 rows is slow - it doesn't matter that much what platform you use. You might get away with it with test data, but it's probably a bigger pain to change the application later on than to start with the right algorithm.
Thomas Mueller
+1  A: 

This blog post describes a port of Lucene to Objective C. You may try to use the code, though it seems a bit dated.

Yuval F