Class Lookup
Simple Lookup interface for string suggestions.
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
Inherited Members
Namespace: Lucene.Net.Search.Suggest
Assembly: Lucene.Net.Suggest.dll
Syntax
public abstract class Lookup
Constructors
Lookup()
Sole constructor. (For invocation by subclass constructors, typically implicit.)
Declaration
protected Lookup()
Fields
CHARSEQUENCE_COMPARER
A simple char-by-char comparer for string
Declaration
public static readonly IComparer<string> CHARSEQUENCE_COMPARER
Field Value
Type | Description |
---|---|
IComparer<string> |
Properties
Count
Get the number of entries the lookup was built with
Declaration
public abstract long Count { get; }
Property Value
Type | Description |
---|---|
long | total number of suggester entries |
Methods
Build(IDictionary)
Build lookup from a dictionary. Some implementations may require sorted or unsorted keys from the dictionary's iterator - use SortedInputEnumerator or UnsortedInputEnumerator in such case.
Declaration
public virtual void Build(IDictionary dict)
Parameters
Type | Name | Description |
---|---|---|
IDictionary | dict |
Build(IInputEnumerator)
Builds up a new internal Lookup representation based on the given IInputEnumerator. The implementation might re-sort the data internally.
Declaration
public abstract void Build(IInputEnumerator inputEnumerator)
Parameters
Type | Name | Description |
---|---|---|
IInputEnumerator | inputEnumerator |
DoLookup(string, bool, int)
Look up a key and return possible completion for this key.
Declaration
public virtual IList<Lookup.LookupResult> DoLookup(string key, 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. |
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) |
DoLookup(string, IEnumerable<BytesRef>, bool, int)
Look up a key and return possible completion for this key.
Declaration
public abstract 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) |
GetSizeInBytes()
Get the size of the underlying lookup implementation in memory
Declaration
public abstract long GetSizeInBytes()
Returns
Type | Description |
---|---|
long | ram size of the lookup implementation in bytes |
Load(DataInput)
Discard current lookup data and load it from a previously saved copy. Optional operation.
Declaration
public abstract bool Load(DataInput input)
Parameters
Type | Name | Description |
---|---|---|
DataInput | input | the Lucene.Net.Store.DataInput to load the lookup data. |
Returns
Type | Description |
---|---|
bool | true if completed successfully, false if unsuccessful or not supported. |
Exceptions
Type | Condition |
---|---|
IOException | when fatal IO error occurs. |
Load(Stream)
Calls Load(DataInput) after converting Stream to Lucene.Net.Store.DataInput
Declaration
public virtual bool Load(Stream input)
Parameters
Type | Name | Description |
---|---|---|
Stream | input |
Returns
Type | Description |
---|---|
bool |
Store(DataOutput)
Persist the constructed lookup data to a directory. Optional operation.
Declaration
public abstract bool Store(DataOutput output)
Parameters
Type | Name | Description |
---|---|---|
DataOutput | output | Lucene.Net.Store.DataOutput to write the data to. |
Returns
Type | Description |
---|---|
bool | true if successful, false if unsuccessful or not supported. |
Exceptions
Type | Condition |
---|---|
IOException | when fatal IO error occurs. |
Store(Stream)
Calls Store(DataOutput) after converting Stream to Lucene.Net.Store.DataOutput
Declaration
public virtual bool Store(Stream output)
Parameters
Type | Name | Description |
---|---|---|
Stream | output |
Returns
Type | Description |
---|---|
bool |