public class SuggestField extends Field
Field that indexes a string value and a weight as a weighted completion against a named suggester. Field is tokenized, not stored and stores documents, frequencies and positions. Field can be used to provide near real time document suggestions.
Besides the usual Analyzer
s,
CompletionAnalyzer
can be used to tune suggest field only parameters
(e.g. preserving token separators, preserving position increments
when converting the token stream to an automaton)
Example indexing usage:
document.add(new SuggestField(name, "suggestion", 4));To perform document suggestions based on the this field, use
SuggestIndexSearcher.suggest(CompletionQuery, int, boolean)
Field.Store
Modifier and Type | Field and Description |
---|---|
static FieldType |
FIELD_TYPE
Default field type for suggest field
|
fieldsData, name, tokenStream, type
Constructor and Description |
---|
SuggestField(String name,
String value,
int weight)
Creates a
SuggestField |
Modifier and Type | Method and Description |
---|---|
TokenStream |
tokenStream(Analyzer analyzer,
TokenStream reuse) |
protected byte |
type()
Returns a byte to denote the type of the field
|
protected CompletionTokenStream |
wrapTokenStream(TokenStream stream)
Wraps a
stream with a CompletionTokenStream. |
binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStreamValue, toString
public static final FieldType FIELD_TYPE
public SuggestField(String name, String value, int weight)
SuggestField
name
- field namevalue
- field value to get suggestions onweight
- field weightIllegalArgumentException
- if either the name or value is null,
if value is an empty string, if the weight is negative, if value contains
any reserved characterspublic TokenStream tokenStream(Analyzer analyzer, TokenStream reuse)
tokenStream
in interface IndexableField
tokenStream
in class Field
protected CompletionTokenStream wrapTokenStream(TokenStream stream)
stream
with a CompletionTokenStream.
Subclasses can override this method to change the indexing pipeline.protected byte type()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.