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 00011 CL_CLASS_DEF(store,Directory) 00012 CL_CLASS_DEF(document,Document) 00013 CL_CLASS_DEF(index, IndexWriter) 00014 CL_CLASS_DEF(index, IndexReader) 00015 CL_CLASS_DEF(index, Term) 00016 CL_CLASS_DEF(index, TermDocs) 00017 CL_CLASS_DEF(index, TermEnum) 00018 #include "CLucene/analysis/AnalysisHeader.h" 00019 //#include "Term.h" 00020 //#include "IndexWriter.h" 00021 //#include "IndexReader.h" 00022 00023 CL_NS_DEF(index) 00024 00025 00074 class IndexModifier :LUCENE_BASE{ 00075 protected: 00076 IndexWriter* indexWriter; 00077 IndexReader* indexReader; 00078 00079 CL_NS(store)::Directory* directory; 00080 CL_NS(analysis)::Analyzer* analyzer; 00081 bool open; 00082 00083 // Lucene defaults: 00084 bool useCompoundFile; 00085 int32_t maxBufferedDocs; 00086 int32_t maxFieldLength; 00087 int32_t mergeFactor; 00088 00089 public: 00090 00099 IndexModifier(CL_NS(store)::Directory* directory, CL_NS(analysis)::Analyzer* analyzer, bool create); 00100 00101 ~IndexModifier(); 00102 00111 IndexModifier(const char* dirName, CL_NS(analysis)::Analyzer* analyzer, bool create); 00112 00113 protected: 00114 00119 void init(CL_NS(store)::Directory* directory, CL_NS(analysis)::Analyzer* analyzer, bool create); 00120 00125 void assureOpen() const; 00126 00131 void createIndexWriter(); 00132 00137 void createIndexReader(); 00138 00139 public: 00144 void flush(); 00145 00154 void addDocument(CL_NS(document)::Document* doc, CL_NS(analysis)::Analyzer* docAnalyzer=NULL); 00155 00156 00167 int32_t deleteDocuments(Term* term); 00168 00174 void deleteDocument(int32_t docNum); 00175 00182 int32_t docCount(); 00183 00190 void optimize(); 00191 00199 void setUseCompoundFile(bool useCompoundFile); 00200 00205 bool getUseCompoundFile(); 00206 00221 void setMaxFieldLength(int32_t maxFieldLength); 00222 00227 int32_t getMaxFieldLength(); 00228 00243 void setMaxBufferedDocs(int32_t maxBufferedDocs); 00244 00249 int32_t getMaxBufferedDocs(); 00250 00264 void setMergeFactor(int32_t mergeFactor); 00265 00270 int32_t getMergeFactor(); 00271 00277 void close(); 00278 00279 TCHAR* toString() const; 00280 00284 int64_t getCurrentVersion() const; 00285 00293 TermDocs* termDocs(Term* term=NULL); 00294 00306 TermEnum* terms(Term* term=NULL); 00307 00315 bool document(const int32_t n, CL_NS(document)::Document* doc); 00316 _CL_DEPRECATED( document(i, document) ) CL_NS(document)::Document* document(const int32_t n); 00317 00321 CL_NS(store)::Directory* getDirectory(); 00322 }; 00323 CL_NS_END 00324 #endif 00325 00326