Package org.apache.lucene.index
Class Terms
- java.lang.Object
-
- org.apache.lucene.index.Terms
-
- Direct Known Subclasses:
FieldReader,FilterLeafReader.FilterTerms,MultiTerms
public abstract class Terms extends Object
Access to the terms in a specific field. SeeFields.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description static Terms[]EMPTY_ARRAYZero-length array ofTerms.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTerms()Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intgetDocCount()Returns the number of documents that have at least one term for this field.BytesRefgetMax()Returns the largest term (in lexicographic order) in the field.BytesRefgetMin()Returns the smallest term (in lexicographic order) in the field.ObjectgetStats()Expert: returns additional information about this Terms instance for debugging purposes.abstract longgetSumDocFreq()Returns the sum ofTermsEnum.docFreq()for all terms in this field.abstract longgetSumTotalTermFreq()Returns the sum ofTermsEnum.totalTermFreq()for all terms in this field.static TermsgetTerms(LeafReader reader, String field)abstract booleanhasFreqs()Returns true if documents in this field store per-document term frequency (PostingsEnum.freq()).abstract booleanhasOffsets()Returns true if documents in this field store offsets.abstract booleanhasPayloads()Returns true if documents in this field store payloads.abstract booleanhasPositions()Returns true if documents in this field store positions.TermsEnumintersect(CompiledAutomaton compiled, BytesRef startTerm)Returns a TermsEnum that iterates over all terms and documents that are accepted by the providedCompiledAutomaton.abstract TermsEnumiterator()Returns an iterator that will step through all terms.abstract longsize()Returns the number of terms for this field, or -1 if this measure isn't stored by the codec.
-
-
-
Method Detail
-
getTerms
public static Terms getTerms(LeafReader reader, String field) throws IOException
- Returns:
- terms instance, or an empty instance if
fielddoes not exist in this reader - Throws:
IOException- if an I/O error occurs.
-
iterator
public abstract TermsEnum iterator() throws IOException
Returns an iterator that will step through all terms. This method will not return null.- Throws:
IOException
-
intersect
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException
Returns a TermsEnum that iterates over all terms and documents that are accepted by the providedCompiledAutomaton. If thestartTermis provided then the returned enum will only return terms> startTerm, but you still must call next() first to get to the first term. Note that the providedstartTermmust be accepted by the automaton.This is an expert low-level API and will only work for
NORMALcompiled automata. To handle any compiled automata you should instead useCompiledAutomaton.getTermsEnum(org.apache.lucene.index.Terms)instead.NOTE: the returned TermsEnum cannot seek.
- Throws:
IOException
-
size
public abstract long size() throws IOExceptionReturns the number of terms for this field, or -1 if this measure isn't stored by the codec. Note that, just like other term measures, this measure does not take deleted documents into account.- Throws:
IOException
-
getSumTotalTermFreq
public abstract long getSumTotalTermFreq() throws IOExceptionReturns the sum ofTermsEnum.totalTermFreq()for all terms in this field. Note that, just like other term measures, this measure does not take deleted documents into account.- Throws:
IOException
-
getSumDocFreq
public abstract long getSumDocFreq() throws IOExceptionReturns the sum ofTermsEnum.docFreq()for all terms in this field. Note that, just like other term measures, this measure does not take deleted documents into account.- Throws:
IOException
-
getDocCount
public abstract int getDocCount() throws IOExceptionReturns the number of documents that have at least one term for this field. Note that, just like other term measures, this measure does not take deleted documents into account.- Throws:
IOException
-
hasFreqs
public abstract boolean hasFreqs()
Returns true if documents in this field store per-document term frequency (PostingsEnum.freq()).
-
hasOffsets
public abstract boolean hasOffsets()
Returns true if documents in this field store offsets.
-
hasPositions
public abstract boolean hasPositions()
Returns true if documents in this field store positions.
-
hasPayloads
public abstract boolean hasPayloads()
Returns true if documents in this field store payloads.
-
getMin
public BytesRef getMin() throws IOException
Returns the smallest term (in lexicographic order) in the field. Note that, just like other term measures, this measure does not take deleted documents into account. This returns null when there are no terms.- Throws:
IOException
-
getMax
public BytesRef getMax() throws IOException
Returns the largest term (in lexicographic order) in the field. Note that, just like other term measures, this measure does not take deleted documents into account. This returns null when there are no terms.- Throws:
IOException
-
getStats
public Object getStats() throws IOException
Expert: returns additional information about this Terms instance for debugging purposes.- Throws:
IOException
-
-