Package org.apache.lucene.search
Class FuzzyTermEnum
- java.lang.Object
-
- org.apache.lucene.index.TermEnum
-
- org.apache.lucene.search.FilteredTermEnum
-
- org.apache.lucene.search.FuzzyTermEnum
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public final class FuzzyTermEnum extends FilteredTermEnum
Subclass of FilteredTermEnum for enumerating all terms that are similar to the specified filter term.Term enumerations are always ordered by Term.compareTo(). Each term in the enumeration is greater than all that precede it.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.FilteredTermEnum
actualEnum, currentTerm
-
-
Constructor Summary
Constructors Constructor Description FuzzyTermEnum(IndexReader reader, Term term)
Creates a FuzzyTermEnum with an empty prefix and a minSimilarity of 0.5f.FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity)
Creates a FuzzyTermEnum with an empty prefix.FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity, int prefixLength)
Constructor for enumeration of all terms from specifiedreader
which share a prefix of lengthprefixLength
withterm
and which have a fuzzy similarity >minSimilarity
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the enumeration to further activity, freeing resources.float
difference()
Equality measure on the termboolean
endEnum()
Indicates the end of the enumeration has been reachedprotected boolean
termCompare(Term term)
The termCompare method in FuzzyTermEnum uses Levenshtein distance to calculate the distance between the given term and the comparing term.-
Methods inherited from class org.apache.lucene.search.FilteredTermEnum
docFreq, next, setEnum, term
-
-
-
-
Constructor Detail
-
FuzzyTermEnum
public FuzzyTermEnum(IndexReader reader, Term term) throws IOException
Creates a FuzzyTermEnum with an empty prefix and a minSimilarity of 0.5f.After calling the constructor the enumeration is already pointing to the first valid term if such a term exists.
- Parameters:
reader
-term
-- Throws:
IOException
- See Also:
FuzzyTermEnum(IndexReader, Term, float, int)
-
FuzzyTermEnum
public FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity) throws IOException
Creates a FuzzyTermEnum with an empty prefix.After calling the constructor the enumeration is already pointing to the first valid term if such a term exists.
- Parameters:
reader
-term
-minSimilarity
-- Throws:
IOException
- See Also:
FuzzyTermEnum(IndexReader, Term, float, int)
-
FuzzyTermEnum
public FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity, int prefixLength) throws IOException
Constructor for enumeration of all terms from specifiedreader
which share a prefix of lengthprefixLength
withterm
and 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:
reader
- Delivers terms.term
- Pattern term.minSimilarity
- Minimum required similarity for terms from the reader. Default value is 0.5f.prefixLength
- Length of required common prefix. Default value is 0.- Throws:
IOException
-
-
Method Detail
-
termCompare
protected final boolean termCompare(Term term)
The termCompare method in FuzzyTermEnum uses Levenshtein distance to calculate the distance between the given term and the comparing term.- Specified by:
termCompare
in classFilteredTermEnum
-
difference
public final float difference()
Equality measure on the term- Specified by:
difference
in classFilteredTermEnum
-
endEnum
public final boolean endEnum()
Indicates the end of the enumeration has been reached- Specified by:
endEnum
in classFilteredTermEnum
-
close
public void close() throws IOException
Closes the enumeration to further activity, freeing resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilteredTermEnum
- Throws:
IOException
-
-