Class FuzzyTermsEnum
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Implements
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class FuzzyTermsEnum : TermsEnum, IBytesRefEnumerator
Constructors
FuzzyTermsEnum(Terms, AttributeSource, Term, float, int, bool)
Constructor for enumeration of all terms from specified reader which share a prefix of
length prefixLength with term and which have a fuzzy similarity >
minSimilarity.
Declaration
public FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, float minSimilarity, int prefixLength, bool transpositions)
Parameters
| Type | Name | Description |
|---|---|---|
| Terms | terms | Delivers terms. |
| AttributeSource | atts | AttributeSource created by the rewrite method of MultiTermQuery thats contains information about competitive boosts during rewrite. It is also used to cache DFAs between segment transitions. |
| Term | term | Pattern term. |
| float | minSimilarity | Minimum required similarity for terms from the reader. Pass an integer value representing edit distance. Passing a fraction is deprecated. |
| int | prefixLength | Length of required common prefix. Default value is 0. |
| bool | transpositions | Transpositions |
Exceptions
| Type | Condition |
|---|---|
| IOException | if there is a low-level IO error |
Fields
m_maxEdits
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected int m_maxEdits
Field Value
| Type | Description |
|---|---|
| int |
m_minSimilarity
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly float m_minSimilarity
Field Value
| Type | Description |
|---|---|
| float |
m_raw
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly bool m_raw
Field Value
| Type | Description |
|---|---|
| bool |
m_realPrefixLength
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly int m_realPrefixLength
Field Value
| Type | Description |
|---|---|
| int |
m_scaleFactor
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly float m_scaleFactor
Field Value
| Type | Description |
|---|---|
| float |
m_termLength
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly int m_termLength
Field Value
| Type | Description |
|---|---|
| int |
m_termText
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly int[] m_termText
Field Value
| Type | Description |
|---|---|
| int[] |
m_terms
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected readonly Terms m_terms
Field Value
| Type | Description |
|---|---|
| Terms |
Properties
Comparer
Return the BytesRef Comparer 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.
Declaration
public override IComparer<BytesRef> Comparer { get; }
Property Value
| Type | Description |
|---|---|
| IComparer<BytesRef> |
Overrides
DocFreq
Returns the number of documents containing the current term. Do not call this when the enum is unpositioned.
Declaration
public override int DocFreq { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
See Also
MinSimilarity
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public virtual float MinSimilarity { get; }
Property Value
| Type | Description |
|---|---|
| float |
Ord
Returns ordinal position for current term. This is an optional property (the codec may throw NotSupportedException. Do not call this when the enum is unpositioned.
Declaration
public override long Ord { get; }
Property Value
| Type | Description |
|---|---|
| long |
Overrides
ScaleFactor
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public virtual float ScaleFactor { get; }
Property Value
| Type | Description |
|---|---|
| float |
Term
Returns current term. Do not call this when the enum is unpositioned.
Declaration
public override BytesRef Term { get; }
Property Value
| Type | Description |
|---|---|
| BytesRef |
Overrides
TotalTermFreq
Returns 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.
Declaration
public override long TotalTermFreq { get; }
Property Value
| Type | Description |
|---|---|
| long |
Overrides
Methods
Docs(IBits, DocsEnum, DocsFlags)
Get DocsEnum for 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.
Declaration
public override DocsEnum Docs(IBits liveDocs, DocsEnum reuse, DocsFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| IBits | liveDocs | Unset bits are documents that should not be returned |
| DocsEnum | reuse | Pass a prior DocsEnum for possible reuse |
| DocsFlags | flags | Specifies which optional per-document values you require; DocsFlags |
Returns
| Type | Description |
|---|---|
| DocsEnum |
Overrides
See Also
DocsAndPositions(IBits, DocsAndPositionsEnum, DocsAndPositionsFlags)
Get DocsAndPositionsEnum for 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.
Declaration
public override DocsAndPositionsEnum DocsAndPositions(IBits liveDocs, DocsAndPositionsEnum reuse, DocsAndPositionsFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| IBits | liveDocs | Unset bits are documents that should not be returned |
| DocsAndPositionsEnum | reuse | Pass a prior DocsAndPositionsEnum for possible reuse |
| DocsAndPositionsFlags | flags | Specifies which optional per-position values you require; see DocsAndPositionsFlags. |
Returns
| Type | Description |
|---|---|
| DocsAndPositionsEnum |
Overrides
GetAutomatonEnum(int, BytesRef)
Return an automata-based enum for matching up to editDistance from
lastTerm, if possible
Declaration
protected virtual TermsEnum GetAutomatonEnum(int editDistance, BytesRef lastTerm)
Parameters
| Type | Name | Description |
|---|---|---|
| int | editDistance | |
| BytesRef | lastTerm |
Returns
| Type | Description |
|---|---|
| TermsEnum |
GetTermState()
Expert: Returns the TermsEnums internal state to position the TermsEnum without re-seeking the term dictionary.
NOTE: A seek by GetTermState() might not capture the AttributeSource's state. Callers must maintain the AttributeSource states separatelyDeclaration
public override TermState GetTermState()
Returns
| Type | Description |
|---|---|
| TermState |
Overrides
See Also
MaxEditDistanceChanged(BytesRef, int, bool)
Subclass of TermsEnum for enumerating all terms that are similar to the specified filter term.
Term enumerations are always ordered by Comparer. Each term in the enumeration is greater than all that precede it.
Declaration
protected virtual void MaxEditDistanceChanged(BytesRef lastTerm, int maxEdits, bool init)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | lastTerm | |
| int | maxEdits | |
| bool | init |
MoveNext()
Moves to the next item in the TermsEnum.
The default implementation can and should be overridden with a more optimized version.Declaration
public override bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
SeekCeil(BytesRef)
Seeks to the specified term, if it exists, or to the next (ceiling) term. Returns TermsEnum.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 END, the enum is unpositioned.
Declaration
public override TermsEnum.SeekStatus SeekCeil(BytesRef text)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | text |
Returns
| Type | Description |
|---|---|
| TermsEnum.SeekStatus |
Overrides
SeekExact(BytesRef)
Attempts 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(BytesRef) may
be substantially faster than SeekCeil(BytesRef).
Declaration
public override bool SeekExact(BytesRef text)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | text |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
SeekExact(BytesRef, TermState)
Expert: Seeks a specific position by TermState previously obtained from GetTermState(). Callers should maintain the TermState to use this method. Low-level implementations may position the TermsEnum without re-seeking the term dictionary.
Seeking by TermState should only be used iff the state was obtained from the same TermsEnum instance. NOTE: Using this method with an incompatible TermState might leave this TermsEnum in undefined state. On a segment level TermState instances are compatible only iff the source and the target TermsEnum operate on the same field. If operating on segment level, TermState instances must not be used across segments. NOTE: A seek by TermState might not restore the AttributeSource's state. AttributeSource states must be maintained separately if this method is used.Declaration
public override void SeekExact(BytesRef term, TermState state)
Parameters
| Type | Name | Description |
|---|---|---|
| BytesRef | term | the term the TermState corresponds to |
| TermState | state | the TermState |
Overrides
SeekExact(long)
Seeks to the specified term by ordinal (position) as
previously returned by Ord. The target ord
may be before or after the current ord, and must be
within bounds.
Declaration
public override void SeekExact(long ord)
Parameters
| Type | Name | Description |
|---|---|---|
| long | ord |
Overrides
SetEnum(TermsEnum)
Swap in a new actual enum to proxy to
Declaration
protected virtual void SetEnum(TermsEnum actualEnum)
Parameters
| Type | Name | Description |
|---|---|---|
| TermsEnum | actualEnum |