Class SynonymGraphFilter
- java.lang.Object
- 
- org.apache.lucene.util.AttributeSource
- 
- org.apache.lucene.analysis.TokenStream
- 
- org.apache.lucene.analysis.TokenFilter
- 
- org.apache.lucene.analysis.synonym.SynonymGraphFilter
 
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Unwrappable<TokenStream>
 
 public final class SynonymGraphFilter extends TokenFilter Applies single- or multi-token synonyms from aSynonymMapto an incomingTokenStream, producing a fully correct graph output. This is a replacement forSynonymFilter, which produces incorrect graphs for multi-token synonyms.However, if you use this during indexing, you must follow it with FlattenGraphFilterto squash tokens on top of one another likeSynonymFilter, because the indexer can't directly consume a graph. To get fully correct positional queries when your synonym replacements are multiple tokens, you should instead apply synonyms using thisTokenFilterat query time and translate the resulting graph to aTermAutomatonQuerye.g. usingTokenStreamToTermAutomatonQuery.NOTE: this cannot consume an incoming graph; results will be undefined. - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSourceAttributeSource.State
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringTYPE_SYNONYM- 
Fields inherited from class org.apache.lucene.analysis.TokenFilterinput
 - 
Fields inherited from class org.apache.lucene.analysis.TokenStreamDEFAULT_TOKEN_ATTRIBUTE_FACTORY
 
- 
 - 
Constructor SummaryConstructors Constructor Description SynonymGraphFilter(TokenStream input, SynonymMap synonyms, boolean ignoreCase)Apply previously built synonyms to incoming tokens.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanincrementToken()voidreset()- 
Methods inherited from class org.apache.lucene.analysis.TokenFilterclose, end, unwrap
 - 
Methods inherited from class org.apache.lucene.util.AttributeSourceaddAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString
 
- 
 
- 
- 
- 
Field Detail- 
TYPE_SYNONYMpublic static final String TYPE_SYNONYM - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
SynonymGraphFilterpublic SynonymGraphFilter(TokenStream input, SynonymMap synonyms, boolean ignoreCase) Apply previously built synonyms to incoming tokens.- Parameters:
- input- input tokenstream
- synonyms- synonym map
- ignoreCase- case-folds input for matching with- Character.toLowerCase(int). Note, if you set this to true, it's your responsibility to lowercase the input entries when you create the- SynonymMap
 
 
- 
 - 
Method Detail- 
incrementTokenpublic boolean incrementToken() throws IOException- Specified by:
- incrementTokenin class- TokenStream
- Throws:
- IOException
 
 - 
resetpublic void reset() throws IOException- Overrides:
- resetin class- TokenFilter
- Throws:
- IOException
 
 
- 
 
-