Package org.apache.lucene.index
Class TermContext
java.lang.Object
org.apache.lucene.index.TermContext
Maintains a
IndexReader
TermState
view over
IndexReader
instances containing a single term. The
TermContext
doesn't track if the given TermState
objects are valid, neither if the TermState
instances refer to the
same terms in the associated readers.-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal IndexReaderContext
Holds theIndexReaderContext
of the top-levelIndexReader
, used internally only for asserting. -
Constructor Summary
ConstructorsConstructorDescriptionTermContext
(IndexReaderContext context) Creates an emptyTermContext
from aIndexReaderContext
TermContext
(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq) -
Method Summary
Modifier and TypeMethodDescriptionstatic TermContext
build
(IndexReaderContext context, Term term) void
clear()
Clears theTermContext
internal state and removes all registeredTermState
sint
docFreq()
Returns the accumulated document frequency of allTermState
instances passed toregister(TermState, int, int, long)
.get
(int ord) void
Registers and associates aTermState
with an leaf ordinal.void
setDocFreq
(int docFreq) expert: only available for queries that want to lie about docfreqlong
Returns the accumulated term frequency of allTermState
instances passed toregister(TermState, int, int, long)
.
-
Field Details
-
topReaderContext
Holds theIndexReaderContext
of the top-levelIndexReader
, used internally only for asserting.
-
-
Constructor Details
-
TermContext
Creates an emptyTermContext
from aIndexReaderContext
-
TermContext
public TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
-
-
Method Details
-
build
Creates aTermContext
from a top-levelIndexReaderContext
and the givenTerm
. This method will lookup the given term in all context's leaf readers and register each of the readers containing the term in the returnedTermContext
using the leaf reader's ordinal.Note: the given context must be a top-level context.
- Throws:
IOException
-
clear
public void clear()Clears theTermContext
internal state and removes all registeredTermState
s -
register
Registers and associates aTermState
with an leaf ordinal. The leaf ordinal should be derived from aIndexReaderContext
's leaf ord. -
get
-
docFreq
public int docFreq()Returns the accumulated document frequency of allTermState
instances passed toregister(TermState, int, int, long)
.- Returns:
- the accumulated document frequency of all
TermState
instances passed toregister(TermState, int, int, long)
.
-
totalTermFreq
public long totalTermFreq()Returns the accumulated term frequency of allTermState
instances passed toregister(TermState, int, int, long)
.- Returns:
- the accumulated term frequency of all
TermState
instances passed toregister(TermState, int, int, long)
.
-
setDocFreq
public void setDocFreq(int docFreq) expert: only available for queries that want to lie about docfreq
-