CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_index_IndexModifier_ 00008 #define _lucene_index_IndexModifier_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "CLucene/store/Directory.h" 00015 #include "CLucene/document/Document.h" 00016 #include "CLucene/analysis/AnalysisHeader.h" 00017 #include "Term.h" 00018 #include "IndexWriter.h" 00019 #include "IndexReader.h" 00020 00021 CL_NS_DEF(index) 00022 00023 00072 class IndexModifier :LUCENE_BASE{ 00073 protected: 00074 IndexWriter* indexWriter; 00075 IndexReader* indexReader; 00076 00077 CL_NS(store)::Directory* directory; 00078 CL_NS(analysis)::Analyzer* analyzer; 00079 bool open; 00080 00081 // Lucene defaults: 00082 bool useCompoundFile; 00083 int32_t maxBufferedDocs; 00084 int32_t maxFieldLength; 00085 int32_t mergeFactor; 00086 00087 public: 00088 00097 IndexModifier(CL_NS(store)::Directory* directory, CL_NS(analysis)::Analyzer* analyzer, bool create); 00098 00099 ~IndexModifier(); 00100 00109 IndexModifier(const char* dirName, CL_NS(analysis)::Analyzer* analyzer, bool create); 00110 00111 protected: 00112 00117 void init(CL_NS(store)::Directory* directory, CL_NS(analysis)::Analyzer* analyzer, bool create); 00118 00123 void assureOpen() const; 00124 00129 void createIndexWriter(); 00130 00135 void createIndexReader(); 00136 00137 public: 00142 void flush(); 00143 00152 void addDocument(CL_NS(document)::Document* doc, CL_NS(analysis)::Analyzer* docAnalyzer=NULL); 00153 00154 00165 int32_t deleteDocuments(Term* term); 00166 00172 void deleteDocument(int32_t docNum); 00173 00180 int32_t docCount(); 00181 00188 void optimize(); 00189 00197 void setUseCompoundFile(bool useCompoundFile); 00198 00203 bool getUseCompoundFile(); 00204 00219 void setMaxFieldLength(int32_t maxFieldLength); 00220 00225 int32_t getMaxFieldLength(); 00226 00241 void setMaxBufferedDocs(int32_t maxBufferedDocs); 00242 00247 int32_t getMaxBufferedDocs(); 00248 00262 void setMergeFactor(int32_t mergeFactor); 00263 00268 int32_t getMergeFactor(); 00269 00275 void close(); 00276 00277 TCHAR* toString() const; 00278 00282 int64_t getCurrentVersion() const; 00283 00291 TermDocs* termDocs(Term* term=NULL); 00292 00304 TermEnum* terms(Term* term=NULL); 00305 00313 bool document(const int32_t n, CL_NS(document)::Document* doc); 00314 _CL_DEPRECATED( document(i, document) ) CL_NS(document)::Document* document(const int32_t n); 00315 00319 CL_NS(store)::Directory* getDirectory(); 00320 }; 00321 CL_NS_END 00322 #endif 00323 00324