Package org.apache.lucene.index
Class PruningReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.FilterIndexReader
-
- org.apache.lucene.index.PruningReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cloneable
public class PruningReader extends FilterIndexReader
This class produces a subset of the input index, by removing some postings data according to rules implemented in aTermPruningPolicy
, and optionally it can also remove stored fields of documents according to rules implemented in aStorePruningPolicy
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterIndexReader
FilterIndexReader.FilterTermDocs, FilterIndexReader.FilterTermEnum, FilterIndexReader.FilterTermPositions
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Field Summary
Fields Modifier and Type Field Description protected int
delTermCount
protected int
delVecCount
protected int
docCount
protected int
prunedVecCount
protected StorePruningPolicy
storePolicy
protected int
termCount
protected TermPruningPolicy
termPolicy
protected int
vecCount
-
Fields inherited from class org.apache.lucene.index.FilterIndexReader
in
-
Fields inherited from class org.apache.lucene.index.IndexReader
hasChanges
-
-
Constructor Summary
Constructors Constructor Description PruningReader(IndexReader in, StorePruningPolicy storePolicy, TermPruningPolicy termPolicy)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
document(int n, FieldSelector fieldSelector)
Applies aStorePruningPolicy
to stored fields of a document.FieldInfos
getFieldInfos()
Applies aStorePruningPolicy
to the list of available field infos.IndexReader[]
getSequentialSubReaders()
Expert: returns the sequential sub readers that this reader is logically composed of.TermFreqVector[]
getTermFreqVectors(int docNumber)
AppliesTermPruningPolicy
to terms inside term vectors.TermPositions
termPositions()
AppliesTermPruningPolicy
to term positions.TermEnum
terms()
AppliesTermPruningPolicy
to term enum.-
Methods inherited from class org.apache.lucene.index.FilterIndexReader
directory, docFreq, doClose, doCommit, doDelete, doSetNorm, doUndeleteAll, getCommitUserData, getCoreCacheKey, getDeletesCacheKey, getIndexCommit, getTermFreqVector, getTermFreqVector, getTermFreqVector, getTermInfosIndexDivisor, getUniqueTermCount, getVersion, hasDeletions, hasNorms, isCurrent, isDeleted, isOptimized, maxDoc, norms, norms, numDocs, termDocs, termDocs, terms, toString
-
Methods inherited from class org.apache.lucene.index.IndexReader
acquireWriteLock, addReaderClosedListener, clone, clone, close, commit, commit, decRef, deleteDocument, deleteDocuments, document, doOpenIfChanged, doOpenIfChanged, doOpenIfChanged, doOpenIfChanged, ensureOpen, flush, flush, getCommitUserData, getCurrentVersion, getRefCount, incRef, indexExists, lastModified, listCommits, numDeletedDocs, open, open, open, open, open, open, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChanged, removeReaderClosedListener, reopen, reopen, reopen, reopen, setNorm, setNorm, termPositions, tryIncRef, undeleteAll
-
-
-
-
Field Detail
-
docCount
protected int docCount
-
vecCount
protected int vecCount
-
termCount
protected int termCount
-
delTermCount
protected int delTermCount
-
prunedVecCount
protected int prunedVecCount
-
delVecCount
protected int delVecCount
-
termPolicy
protected TermPruningPolicy termPolicy
-
storePolicy
protected StorePruningPolicy storePolicy
-
-
Constructor Detail
-
PruningReader
public PruningReader(IndexReader in, StorePruningPolicy storePolicy, TermPruningPolicy termPolicy)
Constructor.- Parameters:
in
- input readerstorePolicy
- implementation ofStorePruningPolicy
- if null then stored values will be retained as is.termPolicy
- implementation ofTermPruningPolicy
, must not be null.
-
-
Method Detail
-
getSequentialSubReaders
public IndexReader[] getSequentialSubReaders()
Description copied from class:IndexReader
Expert: returns the sequential sub readers that this reader is logically composed of. For example, IndexSearcher uses this API to drive searching by one sub reader at a time. If this reader is not composed of sequential child readers, it should return null. If this method returns an empty array, that means this reader is a null reader (for example a MultiReader that has no sub readers).NOTE: You should not try using sub-readers returned by this method to make any changes (setNorm, deleteDocument, etc.). While this might succeed for one composite reader (like MultiReader), it will most likely lead to index corruption for other readers (like DirectoryReader obtained through
IndexReader.open(org.apache.lucene.store.Directory)
. Use the parent reader directly.- Overrides:
getSequentialSubReaders
in classFilterIndexReader
-
document
public Document document(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException
Applies aStorePruningPolicy
to stored fields of a document.- Overrides:
document
in classFilterIndexReader
- Parameters:
n
- Get the document at then
th positionfieldSelector
- TheFieldSelector
to use to determine what Fields should be loaded on the Document. May be null, in which case all Fields will be loaded.- Returns:
- The stored fields of the
Document
at the nth position - Throws:
CorruptIndexException
- if the index is corruptIOException
- if there is a low-level IO error- See Also:
Fieldable
,FieldSelector
,SetBasedFieldSelector
,LoadFirstFieldSelector
-
getFieldInfos
public FieldInfos getFieldInfos()
Applies aStorePruningPolicy
to the list of available field infos.- Overrides:
getFieldInfos
in classFilterIndexReader
-
getTermFreqVectors
public TermFreqVector[] getTermFreqVectors(int docNumber) throws IOException
AppliesTermPruningPolicy
to terms inside term vectors.- Overrides:
getTermFreqVectors
in classFilterIndexReader
- Parameters:
docNumber
- document for which term frequency vectors are returned- Returns:
- array of term frequency vectors. May be null if no term vectors have been stored for the specified document.
- Throws:
IOException
- if index cannot be accessed- See Also:
Field.TermVector
-
termPositions
public TermPositions termPositions() throws IOException
AppliesTermPruningPolicy
to term positions.- Overrides:
termPositions
in classFilterIndexReader
- Throws:
IOException
- if there is a low-level IO error
-
terms
public TermEnum terms() throws IOException
AppliesTermPruningPolicy
to term enum.- Overrides:
terms
in classFilterIndexReader
- Throws:
IOException
- if there is a low-level IO error
-
-