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

IndexReader.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 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 public:
41 IndexReader();
42 virtual ~IndexReader();
43
44 LUCENE_CLASS(IndexReader);
45
46 public:
48 enum FieldOption {
50 FIELD_OPTION_ALL,
52 FIELD_OPTION_INDEXED,
54 FIELD_OPTION_STORES_PAYLOADS,
56 FIELD_OPTION_OMIT_TERM_FREQ_AND_POSITIONS,
58 FIELD_OPTION_UNINDEXED,
60 FIELD_OPTION_INDEXED_WITH_TERMVECTOR,
62 FIELD_OPTION_INDEXED_NO_TERMVECTOR,
64 FIELD_OPTION_TERMVECTOR,
66 FIELD_OPTION_TERMVECTOR_WITH_POSITION,
68 FIELD_OPTION_TERMVECTOR_WITH_OFFSET,
70 FIELD_OPTION_TERMVECTOR_WITH_POSITION_OFFSET
71 };
72
73 static const int32_t DEFAULT_TERMS_INDEX_DIVISOR;
74
75 protected:
76 bool closed;
77 bool _hasChanges;
78 int32_t refCount;
79
80 public:
82 int32_t getRefCount();
83
90 void incRef();
91
95 void decRef();
96
99 static IndexReaderPtr open(const DirectoryPtr& directory);
100
106 static IndexReaderPtr open(const DirectoryPtr& directory, bool readOnly);
107
113 static IndexReaderPtr open(const IndexCommitPtr& commit, bool readOnly);
114
122 static IndexReaderPtr open(const DirectoryPtr& directory, const IndexDeletionPolicyPtr& deletionPolicy, bool readOnly);
123
137 static IndexReaderPtr open(const DirectoryPtr& directory, const IndexDeletionPolicyPtr& deletionPolicy, bool readOnly, int32_t termInfosIndexDivisor);
138
147 static IndexReaderPtr open(const IndexCommitPtr& commit, const IndexDeletionPolicyPtr& deletionPolicy, bool readOnly);
148
162 static IndexReaderPtr open(const IndexCommitPtr& commit, const IndexDeletionPolicyPtr& deletionPolicy, bool readOnly, int32_t termInfosIndexDivisor);
163
197 virtual IndexReaderPtr reopen();
198
201 virtual IndexReaderPtr reopen(bool openReadOnly);
202
206 virtual IndexReaderPtr reopen(const IndexCommitPtr& commit);
207
216 virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
217
219 virtual LuceneObjectPtr clone(bool openReadOnly, const LuceneObjectPtr& other = LuceneObjectPtr());
220
224 virtual DirectoryPtr directory();
225
228 static int64_t lastModified(const DirectoryPtr& directory2);
229
234 static int64_t getCurrentVersion(const DirectoryPtr& directory);
235
239 static MapStringString getCommitUserData(const DirectoryPtr& directory);
240
254 virtual int64_t getVersion();
255
258 virtual MapStringString getCommitUserData();
259
274 virtual bool isCurrent();
275
279 virtual bool isOptimized();
280
290 virtual Collection<TermFreqVectorPtr> getTermFreqVectors(int32_t docNumber) = 0;
291
301 virtual TermFreqVectorPtr getTermFreqVector(int32_t docNumber, const String& field) = 0;
302
308 virtual void getTermFreqVector(int32_t docNumber, const String& field, const TermVectorMapperPtr& mapper) = 0;
309
313 virtual void getTermFreqVector(int32_t docNumber, const TermVectorMapperPtr& mapper) = 0;
314
319 static bool indexExists(const DirectoryPtr& directory);
320
322 virtual int32_t numDocs() = 0;
323
326 virtual int32_t maxDoc() = 0;
327
329 int32_t numDeletedDocs();
330
337 virtual DocumentPtr document(int32_t n);
338
359 virtual DocumentPtr document(int32_t n, const FieldSelectorPtr& fieldSelector) = 0;
360
362 virtual bool isDeleted(int32_t n) = 0;
363
365 virtual bool hasDeletions() = 0;
366
368 virtual bool hasChanges();
369
371 virtual bool hasNorms(const String& field);
372
376 virtual ByteArray norms(const String& field) = 0;
377
381 virtual void norms(const String& field, ByteArray norms, int32_t offset) = 0;
382
392 virtual void setNorm(int32_t doc, const String& field, uint8_t value);
393
398 virtual void setNorm(int32_t doc, const String& field, double value);
399
404 virtual TermEnumPtr terms() = 0;
405
410 virtual TermEnumPtr terms(const TermPtr& t) = 0;
411
413 virtual int32_t docFreq(const TermPtr& t) = 0;
414
420 virtual TermDocsPtr termDocs(const TermPtr& term);
421
423 virtual TermDocsPtr termDocs() = 0;
424
432 virtual TermPositionsPtr termPositions(const TermPtr& term);
433
435 virtual TermPositionsPtr termPositions() = 0;
436
442 virtual void deleteDocument(int32_t docNum);
443
450 virtual int32_t deleteDocuments(const TermPtr& term);
451
453 virtual void undeleteAll();
454
455 void flush();
456
459 void flush(MapStringString commitUserData);
460
464 void commit(MapStringString commitUserData);
465
468 void close();
469
473 virtual HashSet<String> getFieldNames(FieldOption fieldOption) = 0;
474
477 virtual IndexCommitPtr getIndexCommit();
478
484 static void main(Collection<String> args);
485
493 static Collection<IndexCommitPtr> listCommits(const DirectoryPtr& dir);
494
504 virtual Collection<IndexReaderPtr> getSequentialSubReaders();
505
506 virtual LuceneObjectPtr getFieldCacheKey();
507
509 virtual LuceneObjectPtr getDeletesCacheKey();
510
515 virtual int64_t getUniqueTermCount();
516
519 virtual int32_t getTermInfosIndexDivisor();
520
521 protected:
522 void ensureOpen();
523
524 static IndexReaderPtr open(const DirectoryPtr& directory, const IndexDeletionPolicyPtr& deletionPolicy, const IndexCommitPtr& commit, bool readOnly, int32_t termInfosIndexDivisor);
525
527 virtual void doSetNorm(int32_t doc, const String& field, uint8_t value) = 0;
528
531 virtual void doDelete(int32_t docNum) = 0;
532
534 virtual void doUndeleteAll() = 0;
535
538 virtual void acquireWriteLock();
539
543 void commit();
544
546 virtual void doCommit(MapStringString commitUserData) = 0;
547
549 virtual void doClose() = 0;
550
551 friend class DirectoryReader;
552 friend class ParallelReader;
553 };
554
555 }
556
557 #endif
Lucene::IndexReader::DEFAULT_TERMS_INDEX_DIVISOR
static const int32_t DEFAULT_TERMS_INDEX_DIVISOR
Definition: IndexReader.h:73
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::TermPtr
boost::shared_ptr< Term > TermPtr
Definition: LuceneTypes.h:233
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition: Collection.h:17
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::TermVectorMapperPtr
boost::shared_ptr< TermVectorMapper > TermVectorMapperPtr
Definition: LuceneTypes.h:254
Lucene::IndexReader::FIELD_OPTION_INDEXED_WITH_TERMVECTOR
All fields which are indexed with termvectors enabled.
Definition: IndexReader.h:60
SegmentInfos.h
Lucene::IndexReader::FIELD_OPTION_ALL
All fields.
Definition: IndexReader.h:50
Lucene::DocumentPtr
boost::shared_ptr< Document > DocumentPtr
Definition: LuceneTypes.h:74
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::ParallelReader
An IndexReader which reads multiple, parallel indexes. Each index added must have the same number of ...
Definition: ParallelReader.h:26
Lucene::DirectoryReader
An IndexReader which reads indexes with multiple segments.
Definition: DirectoryReader.h:19
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::IndexReader::FIELD_OPTION_UNINDEXED
All fields which are not indexed.
Definition: IndexReader.h:58
Lucene::IndexReader::FIELD_OPTION_INDEXED_NO_TERMVECTOR
All fields which are indexed but don't have termvectors enabled.
Definition: IndexReader.h:62
Lucene::TermEnumPtr
boost::shared_ptr< TermEnum > TermEnumPtr
Definition: LuceneTypes.h:235
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::TermDocsPtr
boost::shared_ptr< TermDocs > TermDocsPtr
Definition: LuceneTypes.h:236
Lucene::IndexReader::FIELD_OPTION_TERMVECTOR_WITH_OFFSET
All fields with termvectors with offset values enabled.
Definition: IndexReader.h:68
Lucene::HashSet< String >
Lucene::IndexReader
IndexReader is an abstract class, providing an interface for accessing an index. Search of an index i...
Definition: IndexReader.h:39
Lucene::TermFreqVectorPtr
boost::shared_ptr< TermFreqVector > TermFreqVectorPtr
Definition: LuceneTypes.h:237
Lucene::IndexReader::FIELD_OPTION_OMIT_TERM_FREQ_AND_POSITIONS
All fields that omit tf.
Definition: IndexReader.h:56
Lucene::IndexReader::FIELD_OPTION_STORES_PAYLOADS
All fields that store payloads.
Definition: IndexReader.h:54
Lucene::IndexReader::FieldOption
FieldOption
Constants describing field properties, for example used for IndexReader#getFieldNames(FieldOption).
Definition: IndexReader.h:48
Lucene::TermPositionsPtr
boost::shared_ptr< TermPositions > TermPositionsPtr
Definition: LuceneTypes.h:243
Lucene::IndexReader::FIELD_OPTION_TERMVECTOR_WITH_POSITION
All fields with termvectors with position values enabled.
Definition: IndexReader.h:66
Lucene::IndexDeletionPolicyPtr
boost::shared_ptr< IndexDeletionPolicy > IndexDeletionPolicyPtr
Definition: LuceneTypes.h:153
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::IndexReader::FIELD_OPTION_TERMVECTOR
All fields with termvectors enabled. Please note that only standard termvector fields are returned.
Definition: IndexReader.h:64
Lucene::IndexReader::_hasChanges
bool _hasChanges
Definition: IndexReader.h:77
Lucene::FieldSelectorPtr
boost::shared_ptr< FieldSelector > FieldSelectorPtr
Definition: LuceneTypes.h:77
Lucene::IndexReader::closed
bool closed
Definition: IndexReader.h:76
Lucene::IndexReader::refCount
int32_t refCount
Definition: IndexReader.h:78
Lucene::IndexCommitPtr
boost::shared_ptr< IndexCommit > IndexCommitPtr
Definition: LuceneTypes.h:152
Lucene::IndexReader::FIELD_OPTION_INDEXED
All indexed fields.
Definition: IndexReader.h:52

clucene.sourceforge.net