Class FSTCompletion
java.lang.Object
org.apache.lucene.search.suggest.fst.FSTCompletion
Finite state automata based implementation of "autocomplete" functionality.
- See Also:
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A single completion for a given key. -
Field Summary
-
Constructor Summary
ConstructorDescriptionFSTCompletion
(FST<Object> automaton) Defaults to higher weights first and exact first.FSTCompletion
(FST<Object> automaton, boolean higherWeightsFirst, boolean exactFirst) Constructs an FSTCompletion, specifying higherWeightsFirst and exactFirst. -
Method Summary
Modifier and TypeMethodDescriptionint
getBucket
(CharSequence key) Returns the bucket assigned to a given key (if found) or-1
if no exact match exists.int
Returns the bucket count (discretization thresholds).getFST()
Returns the internal automaton.lookup
(CharSequence key, int num) Lookup suggestions tokey
.
-
Field Details
-
DEFAULT_BUCKETS
public static final int DEFAULT_BUCKETSDefault number of buckets.- See Also:
-
-
Constructor Details
-
FSTCompletion
Constructs an FSTCompletion, specifying higherWeightsFirst and exactFirst.- Parameters:
automaton
- Automaton with completions. SeeFSTCompletionBuilder
.higherWeightsFirst
- Return most popular suggestions first. This is the default behavior for this implementation. Setting it tofalse
has no effect (use constant term weights to sort alphabetically only).exactFirst
- Find and push an exact match to the first position of the result list if found.
-
FSTCompletion
Defaults to higher weights first and exact first.- See Also:
-
-
Method Details
-
lookup
Lookup suggestions tokey
.- Parameters:
key
- The prefix to which suggestions should be sought.num
- At most this number of suggestions will be returned.- Returns:
- Returns the suggestions, sorted by their approximated weight first (decreasing) and then alphabetically (UTF-8 codepoint order).
-
getBucketCount
public int getBucketCount()Returns the bucket count (discretization thresholds). -
getBucket
Returns the bucket assigned to a given key (if found) or-1
if no exact match exists. -
getFST
Returns the internal automaton.
-