You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Michael Bell <mj...@gwava.com> on 2012/02/22 19:23:18 UTC
Fwd: How to combine StandardAnalyzer with
ReverseWildcardFilter
>>> Michael Bell 2/21/2012 12:18 PM >>>
I've ported over the various pieces from SOLR 3.5 (SolrQueryParser, ReverseWildcardFilter, ReverseWildcardFactory).
But I do not understand how to apply this to indexing.
Here's the situation. Some fields will need StandardAnalyzer, some need KeyWord, some need "SuperAnalyzer" (Standard+ReverseWildcardFilter).
Ok, most of that is easy enough - just use the PerFieldAnalyzerWrapper.
But how to create "SuperAnalyzer".
I started down the road of taking StandardAnalyzer and ReverseWildcardFilter in the constructor of SuperAnalyzer which extends Analyzer,
but I started getting confused which methods to override and how to implement them:
public class SuperAnalyzer extends Analyzer {
final private StandardAnalyzer standard;
final private ReversedWildcardFilterFactory filter;
public SuperAnalyzer(StandardAnalyzer standard,ReversedWildcardFilterFactory filter) { // probably should use Analyzer, TokenFilter for nice generic sig
this.standard=standard; this.filter=filter;
}
@Override
public int getPositionIncrementGap(String fieldName) {
return this.standard.getPositionIncrementGap(fieldName); // or something else
}
@Override
public TokenStream tokenStream(String fieldName, Reader reader) { // this looks ok
TokenStream ts=this.standard.tokenStream(fieldName, reader);
return this.filter.create(ts);
}
@Override
public TokenStream reusableTokenStream(String fieldName, Reader reader)
throws IOException {
return super.reusableTokenStream(fieldName, reader); // this looks wrong, don't know how to fix
}
//
// other methods to override?
}
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org