lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Israel Tsadok <itsa...@gmail.com>
Subject Re: Why has PerFieldAnalyzerWrapper been made final in Lucene 3.1 ?
Date Wed, 04 May 2011 06:56:23 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message