我正在尝试在我的自定义分析器中对 TokenStream 应用多个过滤器。以下是代码:
public class CustomizeAnalyzer extends Analyzer {
//code omitted
@Override
protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
Tokenizer source = new LetterTokenizer(Version.LUCENE_44, reader);
TokenStream filter = new LowerCaseFilter(Version.LUCENE_44, source);
filter = new StopFilter(Version.LUCENE_44, filter, stopWords);
return new TokenStreamComponents(source, new PorterStemFilter(source));
}
}
但是,不会使用 LowerCaseFilter。我从字面上遵循这里的文档。有人可以解释一下如何使它工作吗?
非常感谢,