Class FuzzyTermsEnum
- All Implemented Interfaces:
- BytesRefIterator
Term enumerations are always ordered by
 getComparator().  Each term in the enumeration is
 greater than all that precede it.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfacereuses compiled automata across different segments, because they are independent of the indexstatic final classStores compiled automata as a list (indexed by edit distance)Nested classes/interfaces inherited from class org.apache.lucene.index.TermsEnumTermsEnum.SeekStatus
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intprotected final floatprotected final booleanprotected final intprotected final floatprotected final intprotected final Termsprotected final int[]
- 
Constructor SummaryConstructorsConstructorDescriptionFuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, float minSimilarity, int prefixLength, boolean transpositions) Constructor for enumeration of all terms from specifiedreaderwhich share a prefix of lengthprefixLengthwithtermand which have a fuzzy similarity >minSimilarity.
- 
Method SummaryModifier and TypeMethodDescriptionintdocFreq()Returns the number of documents containing the current term.GetDocsEnumfor the current term, with control over whether freqs are required.docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) GetDocsAndPositionsEnumfor the current term, with control over whether offsets and payloads are required.protected TermsEnumgetAutomatonEnum(int editDistance, BytesRef lastTerm) return an automata-based enum for matching up to editDistance from lastTerm, if possibleReturn theBytesRefComparator used to sort terms provided by the iterator.floatfloatprotected voidmaxEditDistanceChanged(BytesRef lastTerm, int maxEdits, boolean init) next()Increments the iteration to the nextBytesRefin the iterator.longord()Returns ordinal position for current term.Seeks to the specified term, if it exists, or to the next (ceiling) term.voidseekExact(long ord) Seeks to the specified term by ordinal (position) as previously returned byTermsEnum.ord().booleanAttempts to seek to the exact term, returning true if the term is found.voidExpert: Seeks a specific position byTermStatepreviously obtained fromTermsEnum.termState().protected voidswap in a new actual enum to proxy toterm()Returns current term.Expert: Returns the TermsEnums internal state to position the TermsEnum without re-seeking the term dictionary.longReturns the total number of occurrences of this term across all documents (the sum of the freq() for each doc that has this term).Methods inherited from class org.apache.lucene.index.TermsEnumattributes, docs, docsAndPositions
- 
Field Details- 
minSimilarityprotected final float minSimilarity
- 
scale_factorprotected final float scale_factor
- 
termLengthprotected final int termLength
- 
maxEditsprotected int maxEdits
- 
rawprotected final boolean raw
- 
terms
- 
termTextprotected final int[] termText
- 
realPrefixLengthprotected final int realPrefixLength
 
- 
- 
Constructor Details- 
FuzzyTermsEnumpublic FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, float minSimilarity, int prefixLength, boolean transpositions) throws IOException Constructor for enumeration of all terms from specifiedreaderwhich share a prefix of lengthprefixLengthwithtermand which have a fuzzy similarity >minSimilarity.After calling the constructor the enumeration is already pointing to the first valid term if such a term exists. - Parameters:
- terms- Delivers terms.
- atts-- AttributeSourcecreated by the rewrite method of- MultiTermQuerythats contains information about competitive boosts during rewrite. It is also used to cache DFAs between segment transitions.
- term- Pattern term.
- minSimilarity- Minimum required similarity for terms from the reader. Pass an integer value representing edit distance. Passing a fraction is deprecated.
- prefixLength- Length of required common prefix. Default value is 0.
- Throws:
- IOException- if there is a low-level IO error
 
 
- 
- 
Method Details- 
getAutomatonEnumreturn an automata-based enum for matching up to editDistance from lastTerm, if possible- Throws:
- IOException
 
- 
setEnumswap in a new actual enum to proxy to
- 
maxEditDistanceChangedprotected void maxEditDistanceChanged(BytesRef lastTerm, int maxEdits, boolean init) throws IOException - Throws:
- IOException
 
- 
nextDescription copied from interface:BytesRefIteratorIncrements the iteration to the nextBytesRefin the iterator. Returns the resultingBytesRefornullif the end of the iterator is reached. The returned BytesRef may be re-used across calls to next. After this method returns null, do not call it again: the results are undefined.- Returns:
- the next BytesRefin the iterator ornullif the end of the iterator is reached.
- Throws:
- IOException- If there is a low-level I/O error.
 
- 
docFreqDescription copied from class:TermsEnumReturns the number of documents containing the current term. Do not call this when the enum is unpositioned.TermsEnum.SeekStatus.END.- Specified by:
- docFreqin class- TermsEnum
- Throws:
- IOException
 
- 
totalTermFreqDescription copied from class:TermsEnumReturns the total number of occurrences of this term across all documents (the sum of the freq() for each doc that has this term). This will be -1 if the codec doesn't support this measure. Note that, like other term measures, this measure does not take deleted documents into account.- Specified by:
- totalTermFreqin class- TermsEnum
- Throws:
- IOException
 
- 
docsDescription copied from class:TermsEnumGetDocsEnumfor the current term, with control over whether freqs are required. Do not call this when the enum is unpositioned. This method will not return null.- Specified by:
- docsin class- TermsEnum
- Parameters:
- liveDocs- unset bits are documents that should not be returned
- reuse- pass a prior DocsEnum for possible reuse
- flags- specifies which optional per-document values you require; see- DocsEnum.FLAG_FREQS
- Throws:
- IOException
- See Also:
 
- 
docsAndPositionspublic DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException Description copied from class:TermsEnumGetDocsAndPositionsEnumfor the current term, with control over whether offsets and payloads are required. Some codecs may be able to optimize their implementation when offsets and/or payloads are not required. Do not call this when the enum is unpositioned. This will return null if positions were not indexed.- Specified by:
- docsAndPositionsin class- TermsEnum
- Parameters:
- liveDocs- unset bits are documents that should not be returned
- reuse- pass a prior DocsAndPositionsEnum for possible reuse
- flags- specifies which optional per-position values you require; see- DocsAndPositionsEnum.FLAG_OFFSETSand- DocsAndPositionsEnum.FLAG_PAYLOADS.
- Throws:
- IOException
 
- 
seekExactDescription copied from class:TermsEnumExpert: Seeks a specific position byTermStatepreviously obtained fromTermsEnum.termState(). Callers should maintain theTermStateto use this method. Low-level implementations may position the TermsEnum without re-seeking the term dictionary.Seeking by TermStateshould only be used iff the state was obtained from the sameTermsEnuminstance.NOTE: Using this method with an incompatible TermStatemight leave thisTermsEnumin undefined state. On a segment levelTermStateinstances are compatible only iff the source and the targetTermsEnumoperate on the same field. If operating on segment level, TermState instances must not be used across segments.NOTE: A seek by TermStatemight not restore theAttributeSource's state.AttributeSourcestates must be maintained separately if this method is used.- Overrides:
- seekExactin class- TermsEnum
- Parameters:
- term- the term the TermState corresponds to
- state- the- TermState
- Throws:
- IOException
 
- 
termStateDescription copied from class:TermsEnumExpert: Returns the TermsEnums internal state to position the TermsEnum without re-seeking the term dictionary.NOTE: A seek by TermStatemight not capture theAttributeSource's state. Callers must maintain theAttributeSourcestates separately- Overrides:
- termStatein class- TermsEnum
- Throws:
- IOException
- See Also:
 
- 
getComparatorDescription copied from interface:BytesRefIteratorReturn theBytesRefComparator used to sort terms provided by the iterator. This may return null if there are no items or the iterator is not sorted. Callers may invoke this method many times, so it's best to cache a single instance & reuse it.
- 
ordDescription copied from class:TermsEnumReturns ordinal position for current term. This is an optional method (the codec may throwUnsupportedOperationException). Do not call this when the enum is unpositioned.- Specified by:
- ordin class- TermsEnum
- Throws:
- IOException
 
- 
seekExactDescription copied from class:TermsEnumAttempts to seek to the exact term, returning true if the term is found. If this returns false, the enum is unpositioned. For some codecs, seekExact may be substantially faster thanTermsEnum.seekCeil(org.apache.lucene.util.BytesRef).- Overrides:
- seekExactin class- TermsEnum
- Throws:
- IOException
 
- 
seekCeilDescription copied from class:TermsEnumSeeks to the specified term, if it exists, or to the next (ceiling) term. Returns SeekStatus to indicate whether exact term was found, a different term was found, or EOF was hit. The target term may be before or after the current term. If this returns SeekStatus.END, the enum is unpositioned.- Specified by:
- seekCeilin class- TermsEnum
- Throws:
- IOException
 
- 
seekExactDescription copied from class:TermsEnumSeeks to the specified term by ordinal (position) as previously returned byTermsEnum.ord(). The target ord may be before or after the current ord, and must be within bounds.- Specified by:
- seekExactin class- TermsEnum
- Throws:
- IOException
 
- 
termDescription copied from class:TermsEnumReturns current term. Do not call this when the enum is unpositioned.- Specified by:
- termin class- TermsEnum
- Throws:
- IOException
 
- 
getMinSimilaritypublic float getMinSimilarity()
- 
getScaleFactorpublic float getScaleFactor()
 
-