public abstract class Lookup extends Object implements Accountable
CharSequence
suggestions.Modifier and Type | Class and Description |
---|---|
static class |
Lookup.LookupPriorityQueue
A
PriorityQueue collecting a fixed size of high priority Lookup.LookupResult |
static class |
Lookup.LookupResult
Result of a lookup.
|
Modifier and Type | Field and Description |
---|---|
static Comparator<CharSequence> |
CHARSEQUENCE_COMPARATOR
A simple char-by-char comparator for
CharSequence |
Constructor and Description |
---|
Lookup()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
build(Dictionary dict)
Build lookup from a dictionary.
|
abstract void |
build(InputIterator inputIterator)
Builds up a new internal
Lookup representation based on the given InputIterator . |
abstract long |
getCount()
Get the number of entries the lookup was built with
|
abstract boolean |
load(DataInput input)
Discard current lookup data and load it from a previously saved copy.
|
boolean |
load(InputStream input)
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
boolean onlyMorePopular,
int num)
Look up a key and return possible completion for this key.
|
List<Lookup.LookupResult> |
lookup(CharSequence key,
BooleanQuery contextFilerQuery,
int num,
boolean allTermsRequired,
boolean doHighlight)
Look up a key and return possible completion for this key.
|
abstract List<Lookup.LookupResult> |
lookup(CharSequence key,
Set<BytesRef> contexts,
boolean onlyMorePopular,
int num)
Look up a key and return possible completion for this key.
|
abstract boolean |
store(DataOutput output)
Persist the constructed lookup data to a directory.
|
boolean |
store(OutputStream output)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildResources, ramBytesUsed
public static final Comparator<CharSequence> CHARSEQUENCE_COMPARATOR
CharSequence
public Lookup()
public void build(Dictionary dict) throws IOException
SortedInputIterator
or
UnsortedInputIterator
in such case.IOException
public boolean load(InputStream input) throws IOException
IOException
public boolean store(OutputStream output) throws IOException
IOException
public abstract long getCount() throws IOException
IOException
public abstract void build(InputIterator inputIterator) throws IOException
Lookup
representation based on the given InputIterator
.
The implementation might re-sort the data internally.IOException
public List<Lookup.LookupResult> lookup(CharSequence key, boolean onlyMorePopular, int num) throws IOException
key
- lookup key. Depending on the implementation this may be
a prefix, misspelling, or even infix.onlyMorePopular
- return only more popular resultsnum
- maximum number of results to returnIOException
public abstract List<Lookup.LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, boolean onlyMorePopular, int num) throws IOException
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, BooleanQuery contextFilerQuery, int num, boolean allTermsRequired, boolean doHighlight) throws IOException
key
- the lookup keycontextFilerQuery
- A query for further filtering the result of the key lookupnum
- maximum number of results to returnallTermsRequired
- true is all terms are requireddoHighlight
- set to true if key should be highlightedIOException
- when IO exception occurspublic abstract boolean store(DataOutput output) throws IOException
output
- DataOutput
to write the data to.IOException
- when fatal IO error occurs.public abstract boolean load(DataInput input) throws IOException
input
- the DataInput
to load the lookup data.IOException
- when fatal IO error occurs.Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.