Class ExactFilenameAnalyzer

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class ExactFilenameAnalyzer
    extends org.apache.lucene.analysis.Analyzer
    Custom analyzer designed for supporting exact matching on file names.

    Use when indexing for fields which should support exact matches or when searching for fields which support exact matches for filenames.

    • Nested Class Summary

      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      ExactFilenameAnalyzer​(org.apache.lucene.util.Version version)  
    • Constructor Detail

      • ExactFilenameAnalyzer

        public ExactFilenameAnalyzer​(org.apache.lucene.util.Version version)
    • Method Detail

      • createComponents

        protected org.apache.lucene.analysis.Analyzer.TokenStreamComponents createComponents​(String fieldName,
                                                                                             Reader reader)
        Only create tokens by whitespace, and lowercase each token. Filenames will also be split into tokens by the file extension delimiter ".", but all tokens have the same position. The original filename will also be a token.

        e.g. "filename.txt" -> {"filename.txt", "filename", "txt"}

        Searching for the original filename, the name or the extension will match.

        Only one of the tokens will be matched per search, consider them alternative names for the file to match on.

        Specified by:
        createComponents in class org.apache.lucene.analysis.Analyzer