org.apache.lucene.analysis.commongrams
Class CommonGramsQueryFilter

java.lang.Object
  extended by org.apache.lucene.util.AttributeSource
      extended by org.apache.lucene.analysis.TokenStream
          extended by org.apache.lucene.analysis.TokenFilter
              extended by org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter
All Implemented Interfaces:
Closeable

public final class CommonGramsQueryFilter
extends TokenFilter

Wrap a CommonGramsFilter optimizing phrase queries by only returning single words when they are not a member of a bigram. Example:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
AttributeSource.AttributeFactory, AttributeSource.State
 
Field Summary
 
Fields inherited from class org.apache.lucene.analysis.TokenFilter
input
 
Constructor Summary
CommonGramsQueryFilter(CommonGramsFilter input)
          Constructs a new CommonGramsQueryFilter based on the provided CommomGramsFilter
 
Method Summary
 boolean incrementToken()
          Output bigrams whenever possible to optimize queries.
 boolean isGramType()
          Convenience method to check if the current type is a gram type
 void reset()
          
 
Methods inherited from class org.apache.lucene.analysis.TokenFilter
close, end
 
Methods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, restoreState
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonGramsQueryFilter

public CommonGramsQueryFilter(CommonGramsFilter input)
Constructs a new CommonGramsQueryFilter based on the provided CommomGramsFilter

Parameters:
input - CommonGramsFilter the QueryFilter will use
Method Detail

reset

public void reset()
           throws IOException

Overrides:
reset in class TokenFilter
Throws:
IOException

incrementToken

public boolean incrementToken()
                       throws IOException
Output bigrams whenever possible to optimize queries. Only output unigrams when they are not a member of a bigram. Example:

Specified by:
incrementToken in class TokenStream
Throws:
IOException

isGramType

public boolean isGramType()
Convenience method to check if the current type is a gram type

Returns:
true if the current type is a gram type, false otherwise


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.