public class TwitterAnalyzer extends Analyzer {
private DoubleMetaphone filter = new DoubleMetaphone();
@Override
public TokenStream tokenStream(String fieldName, Reader reader) {
final TokenStream result = new PorterStemFilter(new StopFilter(
true, new StandardTokenizer(Version.LUCENE_CURRENT, reader),
StandardAnalyzer.STOP_WORDS_SET));
TermAttribute termAtt = (TermAttribute) result
.addAttribute(TermAttribute.class);
StringBuilder buf = new StringBuilder();
try {
while (result.incrementToken()) {
String word = new String(termAtt.termBuffer(), 0, termAtt
.termLength());
buf.append(filter.encode(word)).append(" ");
}