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 seperators, 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(String, CharSequence, int, org.apache.lucene.search.Filter)
Example query usage:
SuggestIndexSearcher indexSearcher = .. indexSearcher.suggest(name, "su", 2)
Field.Index, Field.Store, Field.TermVector
boost, fieldsData, name, tokenStream, type
Constructor and Description |
---|
SuggestField(String name,
String value,
long weight)
Creates a
SuggestField |
Modifier and Type | Method and Description |
---|---|
TokenStream |
tokenStream(Analyzer analyzer,
TokenStream reuse) |
binaryValue, boost, fieldType, name, numericValue, readerValue, setBoost, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStreamValue, toString, translateFieldType
public SuggestField(String name, String value, long weight)
SuggestField
name
- of the fieldvalue
- to get suggestions onweight
- weight of the suggestionpublic TokenStream tokenStream(Analyzer analyzer, TokenStream reuse) throws IOException
tokenStream
in interface IndexableField
tokenStream
in class Field
IOException
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.