Package org.apache.lucene.index
Class TermContext
- java.lang.Object
-
- org.apache.lucene.index.TermContext
-
public final class TermContext extends Object
Maintains aIndexReader
TermState
view overIndexReader
instances containing a single term. TheTermContext
doesn't track if the givenTermState
objects are valid, neither if theTermState
instances refer to the same terms in the associated readers.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description TermContext(IndexReaderContext context)
Creates an emptyTermContext
from aIndexReaderContext
TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accumulateStatistics(int docFreq, long totalTermFreq)
Expert: Accumulate term statistics.static 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)
.TermState
get(int ord)
void
register(TermState state, int ord)
Expert: Registers and associates aTermState
with an leaf ordinal.void
register(TermState state, int ord, int docFreq, long totalTermFreq)
Registers and associates aTermState
with an leaf ordinal.String
toString()
long
totalTermFreq()
Returns the accumulated term frequency of allTermState
instances passed toregister(TermState, int, int, long)
.boolean
wasBuiltFor(IndexReaderContext context)
Expert: Return whether thisTermContext
was built for the givenIndexReaderContext
.
-
-
-
Constructor Detail
-
TermContext
public TermContext(IndexReaderContext context)
Creates an emptyTermContext
from aIndexReaderContext
-
TermContext
public TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
-
-
Method Detail
-
wasBuiltFor
public boolean wasBuiltFor(IndexReaderContext context)
Expert: Return whether thisTermContext
was built for the givenIndexReaderContext
. This is typically used for assertions.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
build
public static TermContext build(IndexReaderContext context, Term term) throws IOException
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
public void register(TermState state, int ord, int docFreq, long totalTermFreq)
Registers and associates aTermState
with an leaf ordinal. The leaf ordinal should be derived from aIndexReaderContext
's leaf ord.
-
register
public void register(TermState state, int ord)
Expert: Registers and associates aTermState
with an leaf ordinal. The leaf ordinal should be derived from aIndexReaderContext
's leaf ord. On the contrary toregister(TermState, int, int, long)
this method does NOT update term statistics.
-
accumulateStatistics
public void accumulateStatistics(int docFreq, long totalTermFreq)
Expert: Accumulate term statistics.
-
get
public TermState get(int ord)
-
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)
.
-
-