lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Bell" <>
Subject Fwd: How to combine StandardAnalyzer with ReverseWildcardFilter
Date Wed, 22 Feb 2012 18:23:18 GMT

>>> Michael Bell 2/21/2012 12:18 PM >>>
I've ported over the various pieces from SOLR 3.5 (SolrQueryParser, ReverseWildcardFilter,

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;
	public int getPositionIncrementGap(String fieldName) {
		return this.standard.getPositionIncrementGap(fieldName); // or something else
	public TokenStream tokenStream(String fieldName, Reader reader) { // this looks ok
		TokenStream ts=this.standard.tokenStream(fieldName, reader);
		return this.filter.create(ts);		
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:
For additional commands, e-mail:

View raw message