From 6e5d8f717eee09f2f0f5f8c7b556034f246e400e Mon Sep 17 00:00:00 2001 From: kelson42 Date: Sat, 7 Apr 2012 19:31:11 +0000 Subject: [PATCH] + clucene fix for the new indexer --- src/common/kiwix/cluceneIndexer.cpp | 38 ++++++++++++++--------------- src/common/kiwix/cluceneIndexer.h | 24 +++++++++--------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/common/kiwix/cluceneIndexer.cpp b/src/common/kiwix/cluceneIndexer.cpp index e66ce596d..5b391cbd8 100644 --- a/src/common/kiwix/cluceneIndexer.cpp +++ b/src/common/kiwix/cluceneIndexer.cpp @@ -23,25 +23,23 @@ namespace kiwix { TCHAR buffer[MAX_BUFFER_SIZE]; - CluceneIndexer::CluceneIndexer(const string &zimFilePath, const string &cluceneDirectoryPath) : - Indexer(zimFilePath) { + CluceneIndexer::CluceneIndexer() { + } - this->dir = FSDirectory::getDirectory(cluceneDirectoryPath.c_str(), true); - this->writer = new IndexWriter(dir, &analyzer, true); - writer->setUseCompoundFile(false); + void CluceneIndexer::indexingPrelude(const string &indexPath) { + this->dir = FSDirectory::getDirectory(indexPath.c_str(), true); + this->writer = new IndexWriter(this->dir, &analyzer, true); + this->writer->setUseCompoundFile(false); } - void CluceneIndexer::indexNextPercentPre() { - } - - void CluceneIndexer::indexNextArticle(const string &url, - const string &title, - const string &unaccentedTitle, - const string &keywords, - const string &content, - const string &snippet, - const string &size, - const string &wordCount) { + void CluceneIndexer::index(const string &url, + const string &title, + const string &unaccentedTitle, + const string &keywords, + const string &content, + const string &snippet, + const string &size, + const string &wordCount) { Document doc; @@ -75,11 +73,11 @@ namespace kiwix { this->writer->addDocument(&doc); } - void CluceneIndexer::indexNextPercentPost() { + void CluceneIndexer::flush() { } - - void CluceneIndexer::stopIndexing() { - writer->setUseCompoundFile(true); + + void CluceneIndexer::indexingPostlude() { + this->writer->setUseCompoundFile(true); this->writer->optimize(); this->writer->close(); delete this->writer; diff --git a/src/common/kiwix/cluceneIndexer.h b/src/common/kiwix/cluceneIndexer.h index 98e85db6b..f170b3a55 100644 --- a/src/common/kiwix/cluceneIndexer.h +++ b/src/common/kiwix/cluceneIndexer.h @@ -40,20 +40,20 @@ namespace kiwix { class CluceneIndexer : public Indexer { public: - CluceneIndexer(const string &zimFilePath, const string &cluceneDirectoryPath); + CluceneIndexer(); protected: - void indexNextPercentPre(); - void indexNextArticle(const string &url, - const string &title, - const string &unaccentedTitle, - const string &keywords, - const string &content, - const string &snippet, - const string &size, - const string &wordCount); - void indexNextPercentPost(); - void stopIndexing(); + void indexingPrelude(const string &indexPath); + void index(const string &url, + const string &title, + const string &unaccentedTitle, + const string &keywords, + const string &content, + const string &snippet, + const string &size, + const string &wordCount); + void flush(); + void indexingPostlude(); FSDirectory* dir; IndexWriter* writer;