1474
|
1 package goodjava.lucene.analysis;
|
|
2
|
|
3 import java.io.Reader;
|
|
4 import org.apache.lucene.util.Version;
|
|
5 import org.apache.lucene.analysis.Analyzer;
|
|
6 import org.apache.lucene.analysis.Tokenizer;
|
|
7 import org.apache.lucene.analysis.TokenStream;
|
|
8 import org.apache.lucene.analysis.core.KeywordTokenizer;
|
|
9 import org.apache.lucene.analysis.core.LowerCaseFilter;
|
|
10
|
|
11
|
|
12 public final class LowercaseAnalyzer extends Analyzer {
|
|
13 private final Version matchVersion;
|
|
14
|
|
15 public LowercaseAnalyzer(Version matchVersion) {
|
|
16 this.matchVersion = matchVersion;
|
|
17 }
|
|
18
|
|
19 protected TokenStreamComponents createComponents( String fieldName, Reader reader ) {
|
|
20 Tokenizer source = new KeywordTokenizer(reader);
|
|
21 TokenStream filter = new LowerCaseFilter(matchVersion,source);
|
|
22 return new TokenStreamComponents(source,filter);
|
|
23 }
|
|
24 }
|