在 Lucene 3.6.2 中,它必须如下所示:
import org.apache.lucene.analysis.KeywordAnalyzer;
import org.apache.lucene.analysis.KeywordTokenizer;
import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.LowerCaseTokenizer;
import org.apache.lucene.analysis.ReusableAnalyzerBase;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.util.Version;
public class YourAnalyzer extends ReusableAnalyzerBase {
private final Version version;
public YourAnalyzer(final Version version) {
super();
this.version = version;
}
@Override
protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) {
final Tokenizer source = new KeywordTokenizer(reader);
return new TokenStreamComponents(source, new LowerCaseFilter(this.version, source));
}
}