Class LimitTokenCountAnalyzer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    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:
    LimitTokenCountFilter
    • Constructor Detail

      • LimitTokenCountAnalyzer

        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:
        LimitTokenCountAnalyzer(Analyzer,int,boolean)
      • LimitTokenCountAnalyzer

        public LimitTokenCountAnalyzer​(Analyzer delegate,
                                       int maxTokenCount,
                                       boolean consumeAllTokens)
        Build an analyzer that limits the maximum number of tokens per field.
        Parameters:
        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

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object