Mercurial Hosting > luan
diff src/goodjava/lucene/analysis/LowercaseAnalyzer.java @ 1474:13cbce740e1e
LowercaseAnalyzer
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 17 Apr 2020 21:53:09 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/goodjava/lucene/analysis/LowercaseAnalyzer.java Fri Apr 17 21:53:09 2020 -0600 @@ -0,0 +1,24 @@ +package goodjava.lucene.analysis; + +import java.io.Reader; +import org.apache.lucene.util.Version; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.Tokenizer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.core.KeywordTokenizer; +import org.apache.lucene.analysis.core.LowerCaseFilter; + + +public final class LowercaseAnalyzer extends Analyzer { + private final Version matchVersion; + + public LowercaseAnalyzer(Version matchVersion) { + this.matchVersion = matchVersion; + } + + protected TokenStreamComponents createComponents( String fieldName, Reader reader ) { + Tokenizer source = new KeywordTokenizer(reader); + TokenStream filter = new LowerCaseFilter(matchVersion,source); + return new TokenStreamComponents(source,filter); + } +}