Class LimitTokenCountAnalyzer

  extended by org.apache.lucene.analysis.Analyzer
      extended by org.apache.lucene.analysis.AnalyzerWrapper
          extended by org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer
All Implemented Interfaces:

public final class LimitTokenCountAnalyzer
extends AnalyzerWrapper

This Analyzer limits the number of tokens while indexing. It is a replacement for the maximum field length setting inside IndexWriter.

See Also:

Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer
Analyzer.GlobalReuseStrategy, Analyzer.PerFieldReuseStrategy, Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
Constructor Summary
LimitTokenCountAnalyzer(Analyzer delegate, int maxTokenCount)
          Build an analyzer that limits the maximum number of tokens per field.
LimitTokenCountAnalyzer(Analyzer delegate, int maxTokenCount, boolean consumeAllTokens)
          Build an analyzer that limits the maximum number of tokens per field.
Method Summary
protected  Analyzer getWrappedAnalyzer(String fieldName)
 String toString()
protected  Analyzer.TokenStreamComponents wrapComponents(String fieldName, Analyzer.TokenStreamComponents components)
Methods inherited from class org.apache.lucene.analysis.AnalyzerWrapper
createComponents, getOffsetGap, getPositionIncrementGap, initReader
Methods inherited from class org.apache.lucene.analysis.Analyzer
close, tokenStream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public LimitTokenCountAnalyzer(Analyzer delegate,
                               int maxTokenCount)
Build an analyzer that limits the maximum number of tokens per field. This analyzer will not consume any tokens beyond the maxTokenCount limit

See Also:


public LimitTokenCountAnalyzer(Analyzer delegate,
                               int maxTokenCount,
                               boolean consumeAllTokens)
Build an analyzer that limits the maximum number of tokens per field.

delegate - the analyzer to wrap
maxTokenCount - max number of tokens to produce
consumeAllTokens - whether all tokens from the delegate should be consumed even if maxTokenCount is reached.
Method Detail


protected Analyzer getWrappedAnalyzer(String fieldName)
Specified by:
getWrappedAnalyzer in class AnalyzerWrapper


protected Analyzer.TokenStreamComponents wrapComponents(String fieldName,
                                                        Analyzer.TokenStreamComponents components)
Specified by:
wrapComponents in class AnalyzerWrapper


public String toString()
toString in class Object

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