public class FuzzyCompletionQuery extends PrefixCompletionQuery
CompletionQuery that match documents containing terms
within an edit distance of the specified prefix.
This query boost documents relative to how similar the indexed terms are to the provided prefix.
Example usage of querying an analyzed prefix within an edit distance of 1 of 'subg' against a field 'suggest_field' is as follows:
CompletionQuery query = new FuzzyCompletionQuery(analyzer, new Term("suggest_field", "subg"));
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_EDITS
The default maximum number of edits for fuzzy
suggestions.
|
static int |
DEFAULT_MIN_FUZZY_LENGTH
The default minimum length of the key before any edits are allowed.
|
static int |
DEFAULT_NON_FUZZY_PREFIX
The default prefix length where edits are not allowed.
|
static boolean |
DEFAULT_TRANSPOSITIONS
The default transposition value passed to
LevenshteinAutomata |
static boolean |
DEFAULT_UNICODE_AWARE
Measure maxEdits, minFuzzyLength, transpositions and nonFuzzyPrefix
parameters in Unicode code points (actual letters)
instead of bytes.
|
analyzer| Constructor and Description |
|---|
FuzzyCompletionQuery(Analyzer analyzer,
Term term)
Calls
FuzzyCompletionQuery(Analyzer, Term, BitsProducer)
with no filter |
FuzzyCompletionQuery(Analyzer analyzer,
Term term,
BitsProducer filter)
Calls
FuzzyCompletionQuery(Analyzer, Term, BitsProducer,
int, boolean, int, int, boolean, int)
with defaults for maxEdits, transpositions,
nonFuzzyPrefix, minFuzzyLength,
unicodeAware and maxDeterminizedStates
See DEFAULT_MAX_EDITS, DEFAULT_TRANSPOSITIONS,
DEFAULT_NON_FUZZY_PREFIX, DEFAULT_MIN_FUZZY_LENGTH,
DEFAULT_UNICODE_AWARE and Operations.DEFAULT_MAX_DETERMINIZED_STATES
for defaults |
FuzzyCompletionQuery(Analyzer analyzer,
Term term,
BitsProducer filter,
int maxEdits,
boolean transpositions,
int nonFuzzyPrefix,
int minFuzzyLength,
boolean unicodeAware,
int maxDeterminizedStates)
Constructs an analyzed fuzzy prefix completion query
|
| Modifier and Type | Method and Description |
|---|---|
Weight |
createWeight(IndexSearcher searcher,
ScoreMode scoreMode,
float boost) |
int |
getMaxDeterminizedStates()
Get the maximum number of determinized states permitted
|
int |
getMaxEdits()
Get the maximum edit distance for fuzzy matches
|
int |
getMinFuzzyLength()
Get the minimum length of a term considered for matching
|
int |
getNonFuzzyPrefix()
Get the length of a prefix where no edits are permitted
|
boolean |
isTranspositions()
Return whether transpositions count as a single edit
|
boolean |
isUnicodeAware()
Return true if lengths are measured in unicode code-points rather than bytes
|
String |
toString(String field) |
equals, getAnalyzer, hashCode, visitgetField, getFilter, getTerm, rewriteclassHash, sameClassAs, toStringpublic static final boolean DEFAULT_UNICODE_AWARE
public static final int DEFAULT_MIN_FUZZY_LENGTH
public static final int DEFAULT_NON_FUZZY_PREFIX
public static final int DEFAULT_MAX_EDITS
public static final boolean DEFAULT_TRANSPOSITIONS
LevenshteinAutomatapublic FuzzyCompletionQuery(Analyzer analyzer, Term term)
FuzzyCompletionQuery(Analyzer, Term, BitsProducer)
with no filterpublic FuzzyCompletionQuery(Analyzer analyzer, Term term, BitsProducer filter)
FuzzyCompletionQuery(Analyzer, Term, BitsProducer,
int, boolean, int, int, boolean, int)
with defaults for maxEdits, transpositions,
nonFuzzyPrefix, minFuzzyLength,
unicodeAware and maxDeterminizedStates
See DEFAULT_MAX_EDITS, DEFAULT_TRANSPOSITIONS,
DEFAULT_NON_FUZZY_PREFIX, DEFAULT_MIN_FUZZY_LENGTH,
DEFAULT_UNICODE_AWARE and Operations.DEFAULT_MAX_DETERMINIZED_STATES
for defaultspublic FuzzyCompletionQuery(Analyzer analyzer, Term term, BitsProducer filter, int maxEdits, boolean transpositions, int nonFuzzyPrefix, int minFuzzyLength, boolean unicodeAware, int maxDeterminizedStates)
analyzer - used to analyze the provided Term.text()term - query is run against Term.field() and Term.text()
is analyzed with analyzerfilter - used to query on a sub set of documentsmaxEdits - maximum number of acceptable editstranspositions - value passed to LevenshteinAutomatanonFuzzyPrefix - prefix length where edits are not allowedminFuzzyLength - minimum prefix length before any edits are allowedunicodeAware - treat prefix as unicode rather than bytesmaxDeterminizedStates - maximum automaton states allowed for LevenshteinAutomatapublic Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
createWeight in class PrefixCompletionQueryIOExceptionpublic int getMaxEdits()
public boolean isTranspositions()
public int getNonFuzzyPrefix()
public int getMinFuzzyLength()
public boolean isUnicodeAware()
public int getMaxDeterminizedStates()
public String toString(String field)
toString in class CompletionQueryCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.