+ clucene fix for the new indexer

This commit is contained in:
kelson42 2012-04-07 19:31:11 +00:00
parent 5aacc01d65
commit 6e5d8f717e
2 changed files with 30 additions and 32 deletions

View File

@ -23,25 +23,23 @@ namespace kiwix {
TCHAR buffer[MAX_BUFFER_SIZE]; TCHAR buffer[MAX_BUFFER_SIZE];
CluceneIndexer::CluceneIndexer(const string &zimFilePath, const string &cluceneDirectoryPath) : CluceneIndexer::CluceneIndexer() {
Indexer(zimFilePath) {
this->dir = FSDirectory::getDirectory(cluceneDirectoryPath.c_str(), true);
this->writer = new IndexWriter(dir, &analyzer, true);
writer->setUseCompoundFile(false);
} }
void CluceneIndexer::indexNextPercentPre() { 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::indexNextArticle(const string &url, void CluceneIndexer::index(const string &url,
const string &title, const string &title,
const string &unaccentedTitle, const string &unaccentedTitle,
const string &keywords, const string &keywords,
const string &content, const string &content,
const string &snippet, const string &snippet,
const string &size, const string &size,
const string &wordCount) { const string &wordCount) {
Document doc; Document doc;
@ -75,11 +73,11 @@ namespace kiwix {
this->writer->addDocument(&doc); this->writer->addDocument(&doc);
} }
void CluceneIndexer::indexNextPercentPost() { void CluceneIndexer::flush() {
} }
void CluceneIndexer::stopIndexing() { void CluceneIndexer::indexingPostlude() {
writer->setUseCompoundFile(true); this->writer->setUseCompoundFile(true);
this->writer->optimize(); this->writer->optimize();
this->writer->close(); this->writer->close();
delete this->writer; delete this->writer;

View File

@ -40,20 +40,20 @@ namespace kiwix {
class CluceneIndexer : public Indexer { class CluceneIndexer : public Indexer {
public: public:
CluceneIndexer(const string &zimFilePath, const string &cluceneDirectoryPath); CluceneIndexer();
protected: protected:
void indexNextPercentPre(); void indexingPrelude(const string &indexPath);
void indexNextArticle(const string &url, void index(const string &url,
const string &title, const string &title,
const string &unaccentedTitle, const string &unaccentedTitle,
const string &keywords, const string &keywords,
const string &content, const string &content,
const string &snippet, const string &snippet,
const string &size, const string &size,
const string &wordCount); const string &wordCount);
void indexNextPercentPost(); void flush();
void stopIndexing(); void indexingPostlude();
FSDirectory* dir; FSDirectory* dir;
IndexWriter* writer; IndexWriter* writer;