Lucene++ - a full-featured, c++ search engine
API Documentation

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IndexReader.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef INDEXREADER_H
8 #define INDEXREADER_H
9
10 #include "SegmentInfos.h"
11
12 namespace Lucene
13 {
39 class LPPAPI IndexReader : public LuceneObject
40 {
41 public:
42 IndexReader();
43 virtual ~IndexReader();
44
45 LUCENE_CLASS(IndexReader);
46
47 public:
49 enum FieldOption
50 {
52 FIELD_OPTION_ALL,
54 FIELD_OPTION_INDEXED,
56 FIELD_OPTION_STORES_PAYLOADS,
58 FIELD_OPTION_OMIT_TERM_FREQ_AND_POSITIONS,
60 FIELD_OPTION_UNINDEXED,
62 FIELD_OPTION_INDEXED_WITH_TERMVECTOR,
64 FIELD_OPTION_INDEXED_NO_TERMVECTOR,
66 FIELD_OPTION_TERMVECTOR,
68 FIELD_OPTION_TERMVECTOR_WITH_POSITION,
70 FIELD_OPTION_TERMVECTOR_WITH_OFFSET,
72 FIELD_OPTION_TERMVECTOR_WITH_POSITION_OFFSET
73 };
74
75 static const int32_t DEFAULT_TERMS_INDEX_DIVISOR;
76
77 protected:
78 bool closed;
79 bool _hasChanges;
80 int32_t refCount;
81
82 public:
84 int32_t getRefCount();
85
92 void incRef();
93
97 void decRef();
98
101 static IndexReaderPtr open(DirectoryPtr directory);
102
108 static IndexReaderPtr open(DirectoryPtr directory, bool readOnly);
109
115 static IndexReaderPtr open(IndexCommitPtr commit, bool readOnly);
116
124 static IndexReaderPtr open(DirectoryPtr directory, IndexDeletionPolicyPtr deletionPolicy, bool readOnly);
125
139 static IndexReaderPtr open(DirectoryPtr directory, IndexDeletionPolicyPtr deletionPolicy, bool readOnly, int32_t termInfosIndexDivisor);
140
149 static IndexReaderPtr open(IndexCommitPtr commit, IndexDeletionPolicyPtr deletionPolicy, bool readOnly);
150
164 static IndexReaderPtr open(IndexCommitPtr commit, IndexDeletionPolicyPtr deletionPolicy, bool readOnly, int32_t termInfosIndexDivisor);
165
199 virtual IndexReaderPtr reopen();
200
203 virtual IndexReaderPtr reopen(bool openReadOnly);
204
208 virtual IndexReaderPtr reopen(IndexCommitPtr commit);
209
218 virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
219
221 virtual LuceneObjectPtr clone(bool openReadOnly, LuceneObjectPtr other = LuceneObjectPtr());
222
226 virtual DirectoryPtr directory();
227
230 static int64_t lastModified(DirectoryPtr directory2);
231
236 static int64_t getCurrentVersion(DirectoryPtr directory);
237
241 static MapStringString getCommitUserData(DirectoryPtr directory);
242
256 virtual int64_t getVersion();
257
260 virtual MapStringString getCommitUserData();
261
276 virtual bool isCurrent();
277
281 virtual bool isOptimized();
282
292 virtual Collection<TermFreqVectorPtr> getTermFreqVectors(int32_t docNumber) = 0;
293
303 virtual TermFreqVectorPtr getTermFreqVector(int32_t docNumber, const String& field) = 0;
304
310 virtual void getTermFreqVector(int32_t docNumber, const String& field, TermVectorMapperPtr mapper) = 0;
311
315 virtual void getTermFreqVector(int32_t docNumber, TermVectorMapperPtr mapper) = 0;
316
321 static bool indexExists(DirectoryPtr directory);
322
324 virtual int32_t numDocs() = 0;
325
328 virtual int32_t maxDoc() = 0;
329
331 int32_t numDeletedDocs();
332
339 virtual DocumentPtr document(int32_t n);
340
361 virtual DocumentPtr document(int32_t n, FieldSelectorPtr fieldSelector) = 0;
362
364 virtual bool isDeleted(int32_t n) = 0;
365
367 virtual bool hasDeletions() = 0;
368
370 virtual bool hasChanges();
371
373 virtual bool hasNorms(const String& field);
374
378 virtual ByteArray norms(const String& field) = 0;
379
383 virtual void norms(const String& field, ByteArray norms, int32_t offset) = 0;
384
394 virtual void setNorm(int32_t doc, const String& field, uint8_t value);
395
400 virtual void setNorm(int32_t doc, const String& field, double value);
401
406 virtual TermEnumPtr terms() = 0;
407
412 virtual TermEnumPtr terms(TermPtr t) = 0;
413
415 virtual int32_t docFreq(TermPtr t) = 0;
416
422 virtual TermDocsPtr termDocs(TermPtr term);
423
425 virtual TermDocsPtr termDocs() = 0;
426
434 virtual TermPositionsPtr termPositions(TermPtr term);
435
437 virtual TermPositionsPtr termPositions() = 0;
438
444 virtual void deleteDocument(int32_t docNum);
445
452 virtual int32_t deleteDocuments(TermPtr term);
453
455 virtual void undeleteAll();
456
457 void flush();
458
461 void flush(MapStringString commitUserData);
462
466 void commit(MapStringString commitUserData);
467
470 void close();
471
475 virtual HashSet<String> getFieldNames(FieldOption fieldOption) = 0;
476
479 virtual IndexCommitPtr getIndexCommit();
480
486 static void main(Collection<String> args);
487
495 static Collection<IndexCommitPtr> listCommits(DirectoryPtr dir);
496
506 virtual Collection<IndexReaderPtr> getSequentialSubReaders();
507
508 virtual LuceneObjectPtr getFieldCacheKey();
509
511 virtual LuceneObjectPtr getDeletesCacheKey();
512
517 virtual int64_t getUniqueTermCount();
518
521 virtual int32_t getTermInfosIndexDivisor();
522
523 protected:
524 void ensureOpen();
525
526 static IndexReaderPtr open(DirectoryPtr directory, IndexDeletionPolicyPtr deletionPolicy, IndexCommitPtr commit, bool readOnly, int32_t termInfosIndexDivisor);
527
529 virtual void doSetNorm(int32_t doc, const String& field, uint8_t value) = 0;
530
533 virtual void doDelete(int32_t docNum) = 0;
534
536 virtual void doUndeleteAll() = 0;
537
540 virtual void acquireWriteLock();
541
545 void commit();
546
548 virtual void doCommit(MapStringString commitUserData) = 0;
549
551 virtual void doClose() = 0;
552
553 friend class DirectoryReader;
554 friend class ParallelReader;
555 };
556 }
557
558 #endif

clucene.sourceforge.net