Class LengthFilter

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

    public final class LengthFilter
    extends FilteringTokenFilter
    Removes words that are too long or too short from the stream.

    Note: Length is calculated as the number of UTF-16 code units.

    • Constructor Detail

      • LengthFilter

        @Deprecated
        public LengthFilter​(Version version,
                            boolean enablePositionIncrements,
                            TokenStream in,
                            int min,
                            int max)
        Deprecated.
        enablePositionIncrements=false is not supported anymore as of Lucene 4.4.
      • LengthFilter

        public LengthFilter​(Version version,
                            TokenStream in,
                            int min,
                            int max)
        Create a new LengthFilter. This will filter out tokens whose CharTermAttribute is either too short (CharSequence.length() < min) or too long (CharSequence.length() > max).
        Parameters:
        version - the Lucene match version
        in - the TokenStream to consume
        min - the minimum length
        max - the maximum length
    • Method Detail

      • accept

        public boolean accept()