lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <paul_t...@fastmail.fm>
Subject Re: Why has PerFieldAnalyzerWrapper been made final in Lucene 3.1 ?
Date Wed, 04 May 2011 09:21:48 GMT

On 04/05/2011 07:56, Israel Tsadok wrote:
>
> On Tue, May 3, 2011 at 7:03 PM, Paul Taylor <paul_t100@fastmail.fm 
> <mailto: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.
Yeah, actually I independentently ended up doing that, so not a big 
deal, thanks.

Paul


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