好的,測試我有6本雜誌,每本都有自己的索引。因此指數大小爲:
434KB,41KB,139KB,434KB,57KB和57KB
我的索引代碼是:
LCSimpleAnalyzer *analyzer = [[LCSimpleAnalyzeralloc] init];
LCIndexWriter *writer = [[LCIndexWriteralloc] initWithDirectory:[selfcreateFileDirectoryWithEmagPath:emagModel.emagPath] analyzer: analyzer create: YES];
...
// creating searchResult
...
// adding relevant information to lucene document
LCDocument *doc = [[LCDocumentalloc] init];
LCField *fieldContent = [[LCFieldalloc] initWithName: @"content_to_search"string:bodyText store:LCStore_YES index:LCIndex_Tokenized];
LCField *fieldResult = [[LCFieldalloc] initWithName:@"data" data: [NSKeyedArchiverarchivedDataWithRootObject:result] store:LCStore_YES];
[doc addField:fieldContent];
[doc addField:fieldResult];
[writer addDocument:doc];
...
// releasing stuff and close writer
而這對於搜索代碼:
// search
LCIndexSearcher *searcher = [[LCIndexSearcheralloc] initWithDirectory: [selfgetFileDirectoryOfEmagPath:emagPath]];
LCTerm *term = [[LCTermalloc] initWithField: @"content_to_search" text: self.searchText];
LCTermQuery *termQuery = [[LCTermQueryalloc] initWithTerm:term];
LCHits *hits = [searcher search:termQuery];
thx
這些響應時間非常高,特別是對於簡單的術語查詢......我不相信有n在庫代碼或客戶端代碼中確實存在錯誤。雖然我對Lucene很熟悉,但我對iOS並不熟悉。 iOS上有沒有可用的分析工具可以幫助您找到瓶頸? – jpountz 2012-07-14 16:45:40
是的,它們有點高,但是如果你比較時間,它們會以8的最大因子來區分,這就讓我感到困惑。所以「天文學」這個詞只需要1秒,而「標記」這個詞需要超過8秒。這是爲什麼? – 2012-07-19 09:32:30