public class AnalyzingInfixSuggester extends Lookup implements Closeable
This just uses an ordinary Lucene index. It
supports payloads, and records these as a
BinaryDocValues field. Matches are sorted only
by the suggest weight; it would be nice to support
blended score + weight sort in the future. This means
this suggester best applies when there is a strong
apriori ranking of all the suggestions.
Lookup.LookupPriorityQueue, Lookup.LookupResult| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MIN_PREFIX_CHARS
Default minimum number of leading characters before
PrefixQuery is used (4).
|
CHARSEQUENCE_COMPARATOR| Constructor and Description |
|---|
AnalyzingInfixSuggester(Version matchVersion,
File indexPath,
Analyzer analyzer)
Create a new instance, loading from a previously built
directory, if it exists.
|
AnalyzingInfixSuggester(Version matchVersion,
File indexPath,
Analyzer indexAnalyzer,
Analyzer queryAnalyzer,
int minPrefixChars)
Create a new instance, loading from a previously built
directory, if it exists.
|
| Modifier and Type | Method and Description |
|---|---|
void |
build(InputIterator iter)
Builds up a new internal
Lookup representation based on the given InputIterator. |
void |
close() |
long |
getCount()
Get the number of entries the lookup was built with
|
boolean |
load(DataInput out)
Discard current lookup data and load it from a previously saved copy.
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
boolean onlyMorePopular,
int num)
Look up a key and return possible completion for this key.
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
int num,
boolean allTermsRequired,
boolean doHighlight)
Retrieve suggestions, specifying whether all terms
must match (
allTermsRequired) and whether the hits
should be highlighted (doHighlight). |
long |
sizeInBytes()
Get the size of the underlying lookup implementation in memory
|
boolean |
store(DataOutput in)
Persist the constructed lookup data to a directory.
|
public static final int DEFAULT_MIN_PREFIX_CHARS
public AnalyzingInfixSuggester(Version matchVersion, File indexPath, Analyzer analyzer) throws IOException
IOExceptionpublic AnalyzingInfixSuggester(Version matchVersion, File indexPath, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars) throws IOException
minPrefixChars - Minimum number of leading characters
before PrefixQuery is used (default 4).
Prefixes shorter than this are indexed as character
ngrams (increasing index size but making lookups
faster).IOExceptionpublic void build(InputIterator iter) throws IOException
LookupLookup representation based on the given InputIterator.
The implementation might re-sort the data internally.build in class LookupIOExceptionpublic List<Lookup.LookupResult> lookup(CharSequence key, boolean onlyMorePopular, int num)
Lookuplookup in class Lookupkey - lookup key. Depending on the implementation this may be
a prefix, misspelling, or even infix.onlyMorePopular - return only more popular resultsnum - maximum number of results to returnpublic List<Lookup.LookupResult> lookup(CharSequence key, int num, boolean allTermsRequired, boolean doHighlight)
allTermsRequired) and whether the hits
should be highlighted (doHighlight).public boolean store(DataOutput in) throws IOException
Lookupstore in class Lookupin - DataOutput to write the data to.IOException - when fatal IO error occurs.public boolean load(DataInput out) throws IOException
Lookupload in class Lookupout - the DataInput to load the lookup data.IOException - when fatal IO error occurs.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic long sizeInBytes()
LookupsizeInBytes in class LookupCopyright © 2010 - 2020 Adobe. All Rights Reserved