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 Paul Taylor <pa...@fastmail.fm> on 2011/05/03 18:03:09 UTC
Why has PerFieldAnalyzerWrapper been made final in Lucene 3.1 ?
We subclassed PerFieldAnalyzerWrapper as follows:
public class PerFieldEntityAnalyzer extends PerFieldAnalyzerWrapper {
public PerFieldEntityAnalyzer(Class indexFieldClass) {
super(new StandardUnaccentAnalyzer());
for(Object o : EnumSet.allOf(indexFieldClass)) {
IndexField indexField = (IndexField) o;
Analyzer analyzer = indexField.getAnalyzer();
if (analyzer != null) {
this.addAnalyzer(indexField.getName(), analyzer);
}
}
}
}
but now we cant do this.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Why has PerFieldAnalyzerWrapper been made final in Lucene 3.1 ?
Posted by Israel Tsadok <it...@gmail.com>.
On Tue, May 3, 2011 at 7:03 PM, Paul Taylor <pa...@fastmail.fm> wrote:
> We subclassed PerFieldAnalyzerWrapper as follows:
>
> public class PerFieldEntityAnalyzer extends PerFieldAnalyzerWrapper {
>
> public PerFieldEntityAnalyzer(Class indexFieldClass) {
> super(new StandardUnaccentAnalyzer());
>
> for(Object o : EnumSet.allOf(indexFieldClass)) {
> IndexField indexField = (IndexField) o;
> Analyzer analyzer = indexField.getAnalyzer();
> if (analyzer != null) {
> this.addAnalyzer(indexField.getName(), analyzer);
> }
> }
> }
> }
>
> but now we cant do this.
>
> How about:
public static Analyzer createPerFieldEntityAnalyzer(Class indexFieldClass) {
PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new
StandardUnaccentAnalyzer());
for(Object o : EnumSet.allOf(indexFieldClass)) {
IndexField indexField = (IndexField) o;
Analyzer analyzer = indexField.getAnalyzer();
if (analyzer != null) {
wrapper.addAnalyzer(indexField.getName(), analyzer);
}
}
return wrapper;
}
I'm pretty sure that's how you're supposed to use it anyway.