Class PrefixAnalyzer

  • All Implemented Interfaces:
    Closeable, AutoCloseable


    public class PrefixAnalyzer
    extends org.apache.lucene.analysis.Analyzer
    This Analyzer wraps another analyzer and adds a set of prefixes to the underlying TokenStream. While these prefixes are iterated the position attribute will not be incremented. Also each prefix will be separated from the other tokens by a separator character. NOTE: The sequence of prefixes needs to be not empty
    • Nested Class Summary

      Nested Classes

      Modifier and Type Class and Description
      static class  PrefixAnalyzer.PrefixTokenFilter
      The PrefixAnalyzer.PrefixTokenFilter wraps a TokenStream and adds a set prefixes ahead.
      • Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer

        org.apache.lucene.analysis.Analyzer.GlobalReuseStrategy, org.apache.lucene.analysis.Analyzer.PerFieldReuseStrategy, org.apache.lucene.analysis.Analyzer.ReuseStrategy, org.apache.lucene.analysis.Analyzer.TokenStreamComponents
    • Field Summary

      • Fields inherited from class org.apache.lucene.analysis.Analyzer

        GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
    • Method Summary

      Modifier and Type Method and Description
      protected org.apache.lucene.analysis.Analyzer.TokenStreamComponents createComponents(String fieldName, Reader reader)
       
      • Methods inherited from class org.apache.lucene.analysis.Analyzer

        close, getOffsetGap, getPositionIncrementGap, getReuseStrategy, getVersion, initReader, setVersion, tokenStream, tokenStream
    • Constructor Detail

      • PrefixAnalyzer

        public PrefixAnalyzer(org.apache.lucene.analysis.Analyzer analyzer,
                              char separator,
                              CharSequence prefix)
        Create a new PrefixAnalyzer. The separator will be set to the DEFAULT_SEPARATOR.
        Parameters:
        analyzer - Analyzer to wrap
        prefix - Single prefix
      • PrefixAnalyzer

        public PrefixAnalyzer(org.apache.lucene.analysis.Analyzer analyzer,
                              char separator,
                              Iterable<? extends CharSequence> prefix)
        Create a new PrefixAnalyzer. The separator will be set to the DEFAULT_SEPARATOR.
        Parameters:
        analyzer - Analyzer to wrap
        prefix - Iterable of CharSequence which keeps all prefixes
    • Method Detail

      • createComponents

        protected org.apache.lucene.analysis.Analyzer.TokenStreamComponents createComponents(String fieldName,
                                                                                             Reader reader)