Class AnalyzingInfixSuggester
Analyzes the input text and then suggests matches based
on prefix matches to any tokens in the indexed text.
This also highlights the tokens that match.
This suggester supports payloads. 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
a-priori ranking of all the suggestions.
This suggester supports contexts, however the
contexts must be valid utf8 (arbitrary binary terms will
not work).
@lucene.experimental
Inheritance
System.Object
AnalyzingInfixSuggester
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.Suggest.dll
Syntax
public class AnalyzingInfixSuggester : Lookup, IDisposable
Constructors
|
Improve this Doc
View Source
AnalyzingInfixSuggester(LuceneVersion, Directory, Analyzer)
Create a new instance, loading from a previously built
AnalyzingInfixSuggester directory, if it exists.
This directory must be
private to the infix suggester (i.e., not an external
Lucene index). Note that Dispose()
will also dispose the provided directory.
Declaration
public AnalyzingInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer analyzer)
Parameters
|
Improve this Doc
View Source
AnalyzingInfixSuggester(LuceneVersion, Directory, Analyzer, Analyzer, Int32)
Create a new instance, loading from a previously built
AnalyzingInfixSuggester directory, if it exists. This directory must be
private to the infix suggester (i.e., not an external
Lucene index). Note that Dispose()
will also dispose the provided directory.
Declaration
public AnalyzingInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars)
Parameters
Type |
Name |
Description |
LuceneVersion |
matchVersion |
|
Directory |
dir |
|
Analyzer |
indexAnalyzer |
|
Analyzer |
queryAnalyzer |
|
System.Int32 |
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).
|
Fields
|
Improve this Doc
View Source
CONTEXTS_FIELD_NAME
Declaration
protected const string CONTEXTS_FIELD_NAME = "contexts"
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
DEFAULT_MIN_PREFIX_CHARS
Default minimum number of leading characters before
PrefixQuery is used (4).
Declaration
public const int DEFAULT_MIN_PREFIX_CHARS = 4
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
EXACT_TEXT_FIELD_NAME
Field name used for the indexed text, as a
StringField, for exact lookup.
Declaration
protected const string EXACT_TEXT_FIELD_NAME = "exacttext"
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
m_indexAnalyzer
Analyzer used at index time
Declaration
protected readonly Analyzer m_indexAnalyzer
Field Value
|
Improve this Doc
View Source
m_queryAnalyzer
Analyzer used at search time
Declaration
protected readonly Analyzer m_queryAnalyzer
Field Value
|
Improve this Doc
View Source
m_searcherMgr
Declaration
protected SearcherManager m_searcherMgr
Field Value
|
Improve this Doc
View Source
TEXT_FIELD_NAME
Field name used for the indexed text.
Declaration
protected const string TEXT_FIELD_NAME = "text"
Field Value
Type |
Description |
System.String |
|
Properties
|
Improve this Doc
View Source
Count
Declaration
public override long Count { get; }
Property Value
Type |
Description |
System.Int64 |
|
Overrides
Methods
|
Improve this Doc
View Source
Add(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef)
Declaration
public virtual void Add(BytesRef text, IEnumerable<BytesRef> contexts, long weight, BytesRef payload)
Parameters
Type |
Name |
Description |
BytesRef |
text |
|
System.Collections.Generic.IEnumerable<BytesRef> |
contexts |
|
System.Int64 |
weight |
|
BytesRef |
payload |
|
|
Improve this Doc
View Source
AddNonMatch(StringBuilder, String)
Called while highlighting a single result, to append a
non-matching chunk of text from the suggestion to the
provided fragments list.
Declaration
protected virtual void AddNonMatch(StringBuilder sb, string text)
Parameters
Type |
Name |
Description |
System.Text.StringBuilder |
sb |
The System.Text.StringBuilder to append to
|
System.String |
text |
The text chunk to add
|
|
Improve this Doc
View Source
AddPrefixMatch(StringBuilder, String, String, String)
Called while highlighting a single result, to append a
matched prefix token, to the provided fragments list.
Declaration
protected virtual void AddPrefixMatch(StringBuilder sb, string surface, string analyzed, string prefixToken)
Parameters
Type |
Name |
Description |
System.Text.StringBuilder |
sb |
The System.Text.StringBuilder to append to
|
System.String |
surface |
The fragment of the surface form
(indexed during Build(IInputIterator), corresponding to
this match
|
System.String |
analyzed |
The analyzed token that matched
|
System.String |
prefixToken |
The prefix of the token that matched
|
|
Improve this Doc
View Source
AddWholeMatch(StringBuilder, String, String)
Called while highlighting a single result, to append
the whole matched token to the provided fragments list.
Declaration
protected virtual void AddWholeMatch(StringBuilder sb, string surface, string analyzed)
Parameters
Type |
Name |
Description |
System.Text.StringBuilder |
sb |
The System.Text.StringBuilder to append to
|
System.String |
surface |
The surface form (original) text
|
System.String |
analyzed |
The analyzed token corresponding to the surface form text
|
|
Improve this Doc
View Source
Declaration
public override void Build(IInputIterator iter)
Parameters
Overrides
|
Improve this Doc
View Source
CreateResults(IndexSearcher, TopFieldDocs, Int32, String, Boolean, IEnumerable<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 virtual IList<Lookup.LookupResult> CreateResults(IndexSearcher searcher, TopFieldDocs hits, int num, string charSequence, bool doHighlight, IEnumerable<string> matchedTokens, string prefixToken)
Parameters
Type |
Name |
Description |
IndexSearcher |
searcher |
|
TopFieldDocs |
hits |
|
System.Int32 |
num |
|
System.String |
charSequence |
|
System.Boolean |
doHighlight |
|
System.Collections.Generic.IEnumerable<System.String> |
matchedTokens |
|
System.String |
prefixToken |
|
Returns
Exceptions
Type |
Condition |
System.IO.IOException |
If there are problems reading fields from the underlying Lucene index.
|
|
Improve this Doc
View Source
Dispose()
Declaration
public virtual void Dispose()
|
Improve this Doc
View Source
DoLookup(String, IEnumerable<BytesRef>, Boolean, Int32)
Declaration
public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool onlyMorePopular, int num)
Parameters
Type |
Name |
Description |
System.String |
key |
|
System.Collections.Generic.IEnumerable<BytesRef> |
contexts |
|
System.Boolean |
onlyMorePopular |
|
System.Int32 |
num |
|
Returns
Overrides
|
Improve this Doc
View Source
DoLookup(String, IEnumerable<BytesRef>, Int32, Boolean, Boolean)
Retrieve suggestions, specifying whether all terms
must match (allTermsRequired
) and whether the hits
should be highlighted (doHighlight
).
Declaration
public virtual IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, int num, bool allTermsRequired, bool doHighlight)
Parameters
Type |
Name |
Description |
System.String |
key |
|
System.Collections.Generic.IEnumerable<BytesRef> |
contexts |
|
System.Int32 |
num |
|
System.Boolean |
allTermsRequired |
|
System.Boolean |
doHighlight |
|
Returns
|
Improve this Doc
View Source
DoLookup(String, Int32, Boolean, Boolean)
Lookup, without any context.
Declaration
public virtual IList<Lookup.LookupResult> DoLookup(string key, int num, bool allTermsRequired, bool doHighlight)
Parameters
Type |
Name |
Description |
System.String |
key |
|
System.Int32 |
num |
|
System.Boolean |
allTermsRequired |
|
System.Boolean |
doHighlight |
|
Returns
|
Improve this Doc
View Source
FinishQuery(BooleanQuery, Boolean)
Subclass can override this to tweak the Query before
searching.
Declaration
protected virtual Query FinishQuery(BooleanQuery bq, bool allTermsRequired)
Parameters
Type |
Name |
Description |
BooleanQuery |
bq |
|
System.Boolean |
allTermsRequired |
|
Returns
|
Improve this Doc
View Source
GetDirectory(DirectoryInfo)
Subclass can override to choose a specific
Directory implementation.
Declaration
protected virtual Directory GetDirectory(DirectoryInfo path)
Parameters
Type |
Name |
Description |
System.IO.DirectoryInfo |
path |
|
Returns
|
Improve this Doc
View Source
GetIndexWriterConfig(LuceneVersion, Analyzer, OpenMode)
Override this to customize index settings, e.g. which
codec to use.
Declaration
protected virtual IndexWriterConfig GetIndexWriterConfig(LuceneVersion matchVersion, Analyzer indexAnalyzer, OpenMode openMode)
Parameters
Returns
|
Improve this Doc
View Source
GetLastTokenQuery(String)
This is called if the last token isn't ended
(e.g. user did not type a space after it). Return an
appropriate Query clause to add to the BooleanQuery.
Declaration
protected virtual Query GetLastTokenQuery(string token)
Parameters
Type |
Name |
Description |
System.String |
token |
|
Returns
|
Improve this Doc
View Source
GetSizeInBytes()
Declaration
public override long GetSizeInBytes()
Returns
Type |
Description |
System.Int64 |
|
Overrides
|
Improve this Doc
View Source
GetTextFieldType()
Subclass can override this method to change the field type of the text field
e.g. to change the index options
Declaration
protected virtual FieldType GetTextFieldType()
Returns
|
Improve this Doc
View Source
Highlight(String, IEnumerable<String>, String)
Override this method to customize the Object
representing a single highlighted suggestions; the
result is set on each HighlightKey
member.
Declaration
protected virtual object Highlight(string text, IEnumerable<string> matchedTokens, string prefixToken)
Parameters
Type |
Name |
Description |
System.String |
text |
|
System.Collections.Generic.IEnumerable<System.String> |
matchedTokens |
|
System.String |
prefixToken |
|
Returns
Type |
Description |
System.Object |
|
|
Improve this Doc
View Source
Declaration
public override bool Load(DataInput out)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
Refresh()
Reopens the underlying searcher; it's best to "batch
up" many additions/updates, and then call refresh
once in the end.
Declaration
public virtual void Refresh()
|
Improve this Doc
View Source
Store(DataOutput)
Declaration
public override bool Store(DataOutput in)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
Update(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef)
Declaration
public virtual void Update(BytesRef text, IEnumerable<BytesRef> contexts, long weight, BytesRef payload)
Parameters
Type |
Name |
Description |
BytesRef |
text |
|
System.Collections.Generic.IEnumerable<BytesRef> |
contexts |
|
System.Int64 |
weight |
|
BytesRef |
payload |
|
Implements
System.IDisposable