Package org.apache.lucene.analysis.core
Class FlattenGraphFilter
- java.lang.Object
-
- org.apache.lucene.util.AttributeSource
-
- org.apache.lucene.analysis.TokenStream
-
- org.apache.lucene.analysis.TokenFilter
-
- org.apache.lucene.analysis.core.FlattenGraphFilter
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Unwrappable<TokenStream>
public final class FlattenGraphFilter extends TokenFilter
Converts an incoming graph token stream, such as one fromSynonymGraphFilter, into a flat form so that all nodes form a single linear chain with no side paths. Every path through the graph touches every node. This is necessary when indexing a graph token stream, because the index does not savePositionLengthAttributeand so it cannot preserve the graph structure. However, at search time, query parsers can correctly handle the graph and this token filter should not be used.If the graph was not already flat to start, this is likely a lossy process, i.e. it will often cause the graph to accept token sequences it should not, and to reject token sequences it should not.
However, when applying synonyms during indexing, this is necessary because Lucene already does not index a graph and so the indexing process is already lossy (it ignores the
PositionLengthAttribute).- 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.AttributeSource
AttributeSource.State
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.analysis.TokenFilter
input
-
Fields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY
-
-
Constructor Summary
Constructors Constructor Description FlattenGraphFilter(TokenStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidend()intgetMaxLookaheadUsed()For testingbooleanincrementToken()voidreset()-
Methods inherited from class org.apache.lucene.analysis.TokenFilter
close, unwrap
-
Methods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString
-
-
-
-
Constructor Detail
-
FlattenGraphFilter
public FlattenGraphFilter(TokenStream in)
-
-
Method Detail
-
incrementToken
public boolean incrementToken() throws IOException- Specified by:
incrementTokenin classTokenStream- Throws:
IOException
-
end
public void end() throws IOException- Overrides:
endin classTokenFilter- Throws:
IOException
-
reset
public void reset() throws IOException- Overrides:
resetin classTokenFilter- Throws:
IOException
-
getMaxLookaheadUsed
public int getMaxLookaheadUsed()
For testing
-
-