Class BlendedInfixSuggester
Extension of the AnalyzingInfixSuggester which transforms the weight after search to take into account the position of the searched term into the indexed text. Please note that it increases the number of elements searched and applies the ponderation after. It might be costly for long suggestions.
Note
This API is experimental and might change in incompatible ways in the next release.
Implements
Inherited Members
Namespace: Lucene.Net.Search.Suggest.Analyzing
Assembly: Lucene.Net.Suggest.dll
Syntax
public class BlendedInfixSuggester : AnalyzingInfixSuggester, IDisposable
Constructors
BlendedInfixSuggester(LuceneVersion, Directory, Analyzer)
Create a new instance, loading from a previously built directory, if it exists.
Declaration
public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | |
Directory | dir | |
Analyzer | analyzer |
BlendedInfixSuggester(LuceneVersion, Directory, Analyzer, Analyzer, int, BlenderType, int)
Create a new instance, loading from a previously built directory, if it exists.
Declaration
public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | |
Directory | dir | |
Analyzer | indexAnalyzer | |
Analyzer | queryAnalyzer | |
int | minPrefixChars | |
BlendedInfixSuggester.BlenderType | blenderType | Type of blending strategy, see BlenderType for more precisions |
int | numFactor | Factor to multiply the number of searched elements before ponderate |
Exceptions
Type | Condition |
---|---|
IOException | If there are problems opening the underlying Lucene index. |
BlendedInfixSuggester(LuceneVersion, Directory, Analyzer, Analyzer, int, BlenderType, int, bool)
Create a new instance, loading from a previously built directory, if it exists.
Declaration
public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor, bool commitOnBuild)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | |
Directory | dir | |
Analyzer | indexAnalyzer | |
Analyzer | queryAnalyzer | |
int | minPrefixChars | |
BlendedInfixSuggester.BlenderType | blenderType | Type of blending strategy, see BlenderType for more precisions |
int | numFactor | Factor to multiply the number of searched elements before ponderate |
bool | commitOnBuild | 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. |
Exceptions
Type | Condition |
---|---|
IOException | If there are problems opening the underlying Lucene index. |
Fields
DEFAULT_NUM_FACTOR
Default factor
Declaration
public static int DEFAULT_NUM_FACTOR
Field Value
Type | Description |
---|---|
int |
LINEAR_COEF
Coefficient used for linear blending
Declaration
protected static double LINEAR_COEF
Field Value
Type | Description |
---|---|
double |
Methods
CalculateCoefficient(int)
Calculate the weight coefficient based on the position of the first matching word. Subclass should override it to adapt it to particular needs
Declaration
protected virtual double CalculateCoefficient(int position)
Parameters
Type | Name | Description |
---|---|---|
int | position | of the first matching word in text |
Returns
Type | Description |
---|---|
double | the coefficient |
CreateResults(IndexSearcher, TopFieldDocs, int, string, bool, ICollection<string>, string)
Create the results based on the search hits. Can be overridden by subclass to add particular behavior (e.g. weight transformation)
Declaration
protected override IList<Lookup.LookupResult> CreateResults(IndexSearcher searcher, TopFieldDocs hits, int num, string key, bool doHighlight, ICollection<string> matchedTokens, string prefixToken)
Parameters
Type | Name | Description |
---|---|---|
IndexSearcher | searcher | |
TopFieldDocs | hits | |
int | num | |
string | key | |
bool | doHighlight | |
ICollection<string> | matchedTokens | |
string | prefixToken |
Returns
Type | Description |
---|---|
IList<Lookup.LookupResult> |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | If there are problems reading fields from the underlying Lucene index. |
DoLookup(string, IEnumerable<BytesRef>, bool, int)
Look up a key and return possible completion for this key.
Declaration
public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool onlyMorePopular, int num)
Parameters
Type | Name | Description |
---|---|---|
string | key | lookup key. Depending on the implementation this may be a prefix, misspelling, or even infix. |
IEnumerable<BytesRef> | 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 match |
bool | onlyMorePopular | return only more popular results |
int | num | maximum number of results to return |
Returns
Type | Description |
---|---|
IList<Lookup.LookupResult> | a list of possible completions, with their relative weight (e.g. popularity) |
Overrides
DoLookup(string, IEnumerable<BytesRef>, int, bool, bool)
Retrieve suggestions, specifying whether all terms
must match (allTermsRequired
) and whether the hits
should be highlighted (doHighlight
).
Declaration
public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, int num, bool allTermsRequired, bool doHighlight)
Parameters
Type | Name | Description |
---|---|---|
string | key | |
IEnumerable<BytesRef> | contexts | |
int | num | |
bool | allTermsRequired | |
bool | doHighlight |
Returns
Type | Description |
---|---|
IList<Lookup.LookupResult> |
Overrides
GetTextFieldType()
Subclass can override this method to change the field type of the text field e.g. to change the index options
Declaration
protected override FieldType GetTextFieldType()
Returns
Type | Description |
---|---|
FieldType |