On Tue, May 3, 2011 at 7:03 PM, Paul Taylor <paul_t100@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.
|