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.| Modifier and Type | Field and Description |
|---|---|
static int |
CONTEXT_SEPARATOR
Separator used between context value and the suggest field value
|
FIELD_TYPE| Constructor and Description |
|---|
ContextSuggestField(java.lang.String name,
java.lang.String value,
int weight,
java.lang.CharSequence... contexts)
Creates a context-enabled suggest field
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Iterable<java.lang.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. |
tokenStreampublic static final int CONTEXT_SEPARATOR
public ContextSuggestField(java.lang.String name,
java.lang.String value,
int weight,
java.lang.CharSequence... contexts)
name - field namevalue - field value to get suggestion onweight - field weightcontexts - associated contextsjava.lang.IllegalArgumentException - 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 java.lang.Iterable<java.lang.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 SuggestFieldData In Motion GmbH all rights reserved