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_ALL_TERMS_REQUIRED, DEFAULT_HIGHLIGHT, DEFAULT_MIN_PREFIX_CHARS, EXACT_TEXT_FIELD_NAME, indexAnalyzer, queryAnalyzer, searcherMgr, TEXT_FIELD_NAME
CHARSEQUENCE_COMPARATOR
Constructor and Description |
---|
BlendedInfixSuggester(Directory dir,
Analyzer analyzer)
Create a new instance, loading from a previously built
directory, if it exists.
|
BlendedInfixSuggester(Directory dir,
Analyzer indexAnalyzer,
Analyzer queryAnalyzer,
int minPrefixChars,
BlendedInfixSuggester.BlenderType blenderType,
int numFactor,
boolean commitOnBuild)
Create a new instance, loading from a previously built
directory, if it exists.
|
BlendedInfixSuggester(Directory dir,
Analyzer indexAnalyzer,
Analyzer queryAnalyzer,
int minPrefixChars,
BlendedInfixSuggester.BlenderType blenderType,
int numFactor,
boolean commitOnBuild,
boolean allTermsRequired,
boolean highlight)
Create a new instance, loading from a previously built
directory, if it exists.
|
BlendedInfixSuggester(Version matchVersion,
Directory dir,
Analyzer analyzer)
Deprecated.
|
BlendedInfixSuggester(Version matchVersion,
Directory dir,
Analyzer indexAnalyzer,
Analyzer queryAnalyzer,
int minPrefixChars,
BlendedInfixSuggester.BlenderType blenderType,
int numFactor,
boolean commitOnBuild)
|
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,
Map<BytesRef,BooleanClause.Occur> contextInfo,
int num,
boolean allTermsRequired,
boolean doHighlight)
Retrieve suggestions, specifying whether all terms
must match (
allTermsRequired ) and whether the hits
should be highlighted (doHighlight ). |
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)
Lookup, with context but without booleans.
|
add, addNonMatch, addPrefixMatch, addWholeMatch, build, close, commit, finishQuery, getChildResources, getCount, getDirectory, getIndexWriterConfig, getLastTokenQuery, highlight, load, lookup, ramBytesUsed, refresh, store, update
protected static double LINEAR_COEF
public static int DEFAULT_NUM_FACTOR
public BlendedInfixSuggester(Directory dir, Analyzer analyzer) throws IOException
IOException
@Deprecated public BlendedInfixSuggester(Version matchVersion, Directory dir, Analyzer analyzer) throws IOException
BlendedInfixSuggester(Directory, Analyzer)
IOException
public BlendedInfixSuggester(Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor, boolean commitOnBuild) throws IOException
blenderType
- Type of blending strategy, see BlenderType for more precisionsnumFactor
- Factor to multiply the number of searched elements before ponderatecommitOnBuild
- Call commit after the index has finished building. This would persist the
suggester index to disk and future instances of this suggester can use this pre-built dictionary.IOException
- If there are problems opening the underlying Lucene index.@Deprecated public BlendedInfixSuggester(Version matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor, boolean commitOnBuild) throws IOException
BlendedInfixSuggester(Directory, Analyzer, Analyzer, int, BlendedInfixSuggester.BlenderType, int, boolean)
IOException
public BlendedInfixSuggester(Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor, boolean commitOnBuild, boolean allTermsRequired, boolean highlight) throws IOException
blenderType
- Type of blending strategy, see BlenderType for more precisionsnumFactor
- Factor to multiply the number of searched elements before ponderatecommitOnBuild
- Call commit after the index has finished building. This would persist the
suggester index to disk and future instances of this suggester can use this pre-built dictionary.allTermsRequired
- All terms in the suggest query must be matched.highlight
- Highlight suggest query in suggestions.IOException
- 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
Lookup
lookup
in class AnalyzingInfixSuggester
key
- 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 returnIOException
public List<Lookup.LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, int num, boolean allTermsRequired, boolean doHighlight) throws IOException
AnalyzingInfixSuggester
lookup
in class AnalyzingInfixSuggester
IOException
public List<Lookup.LookupResult> lookup(CharSequence key, Map<BytesRef,BooleanClause.Occur> contextInfo, int num, boolean allTermsRequired, boolean doHighlight) throws IOException
AnalyzingInfixSuggester
allTermsRequired
) and whether the hits
should be highlighted (doHighlight
).lookup
in class AnalyzingInfixSuggester
IOException
protected FieldType getTextFieldType()
AnalyzingInfixSuggester
getTextFieldType
in class AnalyzingInfixSuggester
protected List<Lookup.LookupResult> createResults(IndexSearcher searcher, TopFieldDocs hits, int num, CharSequence key, boolean doHighlight, Set<String> matchedTokens, String prefixToken) throws IOException
AnalyzingInfixSuggester
prefixToken
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 AnalyzingInfixSuggester
IOException
- 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.