public class ContextSuggestField extends SuggestField
SuggestField which additionally takes in a set of
contexts. Example usage of adding a suggestion with contexts is as follows:
document.add(
new ContextSuggestField(name, "suggestion", Arrays.asList("context1", "context2"), 4));
Use ContextQuery to boost and/or filter suggestions
at query-time. Use PrefixCompletionQuery, RegexCompletionQuery
or FuzzyCompletionQuery if context boost/filtering
are not needed.Field.Store| Modifier and Type | Field and Description |
|---|---|
static int |
CONTEXT_SEPARATOR
Separator used between context value and the suggest field value
|
FIELD_TYPEfieldsData, name, tokenStream, type| Constructor and Description |
|---|
ContextSuggestField(String name,
String value,
int weight,
CharSequence... contexts)
Creates a context-enabled suggest field
|
| Modifier and Type | Method and Description |
|---|---|
protected Iterable<CharSequence> |
contexts()
Expert: Sub-classes can inject contexts at
index-time
|
protected byte |
type()
Returns a byte to denote the type of the field
|
protected CompletionTokenStream |
wrapTokenStream(TokenStream stream)
Wraps a
stream with a CompletionTokenStream. |
tokenStreambinaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStreamValue, toStringpublic static final int CONTEXT_SEPARATOR
public ContextSuggestField(String name, String value, int weight, CharSequence... contexts)
name - field namevalue - field value to get suggestion onweight - field weightcontexts - associated contextsIllegalArgumentException - if either the name or value is null,
if value is an empty string, if the weight is negative, if value or
contexts contains any reserved charactersprotected Iterable<CharSequence> contexts()
protected CompletionTokenStream wrapTokenStream(TokenStream stream)
SuggestFieldstream with a CompletionTokenStream.
Subclasses can override this method to change the indexing pipeline.wrapTokenStream in class SuggestFieldprotected byte type()
SuggestFieldtype in class SuggestFieldCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.