Class FSTCompletion
- java.lang.Object
-
- org.apache.lucene.search.suggest.fst.FSTCompletion
-
public class FSTCompletion extends java.lang.Object
Finite state automata based implementation of "autocomplete" functionality.- See Also:
FSTCompletionBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FSTCompletion.Completion
A single completion for a given key.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUCKETS
Default number of buckets.
-
Constructor Summary
Constructors Constructor Description FSTCompletion(FST<java.lang.Object> automaton)
Defaults to higher weights first and exact first.FSTCompletion(FST<java.lang.Object> automaton, boolean higherWeightsFirst, boolean exactFirst)
Constructs an FSTCompletion, specifying higherWeightsFirst and exactFirst.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBucket(java.lang.CharSequence key)
Returns the bucket assigned to a given key (if found) or-1
if no exact match exists.int
getBucketCount()
Returns the bucket count (discretization thresholds).FST<java.lang.Object>
getFST()
Returns the internal automaton.java.util.List<FSTCompletion.Completion>
lookup(java.lang.CharSequence key, int num)
Lookup suggestions tokey
.
-
-
-
Field Detail
-
DEFAULT_BUCKETS
public static final int DEFAULT_BUCKETS
Default number of buckets.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FSTCompletion
public FSTCompletion(FST<java.lang.Object> automaton, boolean higherWeightsFirst, boolean exactFirst)
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
public FSTCompletion(FST<java.lang.Object> automaton)
Defaults to higher weights first and exact first.- See Also:
FSTCompletion(FST, boolean, boolean)
-
-
Method Detail
-
lookup
public java.util.List<FSTCompletion.Completion> lookup(java.lang.CharSequence key, int num)
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
public int getBucket(java.lang.CharSequence key)
Returns the bucket assigned to a given key (if found) or-1
if no exact match exists.
-
getFST
public FST<java.lang.Object> getFST()
Returns the internal automaton.
-
-