public class BlendedInfixSuggester extends AnalyzingInfixSuggester
| Modifier and Type | Class and Description |
|---|---|
static class |
BlendedInfixSuggester.BlenderType
The different types of blender.
|
Lookup.LookupPriorityQueue, Lookup.LookupResult| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NUM_FACTOR
Default factor
|
protected static double |
LINEAR_COEF
Coefficient used for linear blending
|
CONTEXTS_FIELD_NAME, DEFAULT_MIN_PREFIX_CHARS, EXACT_TEXT_FIELD_NAME, indexAnalyzer, queryAnalyzer, searcherMgr, TEXT_FIELD_NAMECHARSEQUENCE_COMPARATOR| Constructor and Description |
|---|
BlendedInfixSuggester(Version matchVersion,
Directory dir,
Analyzer analyzer)
Create a new instance, loading from a previously built
directory, if it exists.
|
BlendedInfixSuggester(Version matchVersion,
Directory dir,
Analyzer indexAnalyzer,
Analyzer queryAnalyzer,
int minPrefixChars,
BlendedInfixSuggester.BlenderType blenderType,
int numFactor)
Create a new instance, loading from a previously built
directory, if it exists.
|
| Modifier and Type | Method and Description |
|---|---|
protected double |
calculateCoefficient(int position)
Calculate the weight coefficient based on the position of the first matching word.
|
protected List<Lookup.LookupResult> |
createResults(IndexSearcher searcher,
TopFieldDocs hits,
int num,
CharSequence key,
boolean doHighlight,
Set<String> matchedTokens,
String prefixToken)
Create the results based on the search hits.
|
protected FieldType |
getTextFieldType()
Subclass can override this method to change the field type of the text field
e.g.
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
Set<BytesRef> contexts,
boolean onlyMorePopular,
int num)
Look up a key and return possible completion for this key.
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
Set<BytesRef> contexts,
int num,
boolean allTermsRequired,
boolean doHighlight)
Retrieve suggestions, specifying whether all terms
must match (
allTermsRequired) and whether the hits
should be highlighted (doHighlight). |
add, addNonMatch, addPrefixMatch, addWholeMatch, build, close, finishQuery, getCount, getDirectory, getIndexWriterConfig, getLastTokenQuery, highlight, load, lookup, ramBytesUsed, refresh, store, updateprotected static double LINEAR_COEF
public static int DEFAULT_NUM_FACTOR
public BlendedInfixSuggester(Version matchVersion, Directory dir, Analyzer analyzer) throws IOException
IOExceptionpublic BlendedInfixSuggester(Version matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor) throws IOException
blenderType - Type of blending strategy, see BlenderType for more precisionsnumFactor - Factor to multiply the number of searched elements before ponderateIOException - If there are problems opening the underlying Lucene index.public List<Lookup.LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, boolean onlyMorePopular, int num) throws IOException
Lookuplookup in class AnalyzingInfixSuggesterkey - lookup key. Depending on the implementation this may be
a prefix, misspelling, or even infix.contexts - contexts to filter the lookup by, or null if all contexts are allowed; if the suggestion contains any of the contexts, it's a matchonlyMorePopular - return only more popular resultsnum - maximum number of results to returnIOExceptionpublic List<Lookup.LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, int num, boolean allTermsRequired, boolean doHighlight) throws IOException
AnalyzingInfixSuggesterallTermsRequired) and whether the hits
should be highlighted (doHighlight).lookup in class AnalyzingInfixSuggesterIOExceptionprotected FieldType getTextFieldType()
AnalyzingInfixSuggestergetTextFieldType in class AnalyzingInfixSuggesterprotected List<Lookup.LookupResult> createResults(IndexSearcher searcher, TopFieldDocs hits, int num, CharSequence key, boolean doHighlight, Set<String> matchedTokens, String prefixToken) throws IOException
AnalyzingInfixSuggesterprefixToken argument will
be null) whenever the final token in the incoming request was in fact finished
(had trailing characters, such as white-space).createResults in class AnalyzingInfixSuggesterIOException - If there are problems reading fields from the underlying Lucene index.protected double calculateCoefficient(int position)
position - of the first matching word in textCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.