在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));
}
}