-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: hibernate search - analyzer instantiation?
PostPosted: Tue May 03, 2011 3:50 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Hi,

Could I please ask for advice about instantiation of Analyzers (for hibernate search).

1) I wanted to invoke the parametrized constructor: new SnowballAnalyzer(version, name).
I couldn't find an elegant way to do it...
@Analyzer(impl=classname) doesn't receive constructor parameters.
@AnalyzerDef works, but the examples I see are cumbersome:
Code:
@AnalyzerDefname="englishSnowball",tokenizer =
      @TokenizerDef(factory = StandardTokenizerFactory.class ),
           filters = {@TokenFilterDef(factory=StandardFilterFactory.class),
                        @TokenFilterDef(factory=LowerCaseFilterFactory.class),
                        @TokenFilterDef(factory = StopFilterFactory.class...
       @TokenFilterDef(factory = SnowballPorterFilterFactory.class,
              params = @Parameter(name="language", value="English") )

While I just wanted simple the defaults of SnowballAnalyzer... Is there no elegant way for hibernate search to invoke a parametrized constructor?
Of course I can wrap SnowballAnalyzer with my own Analyzer, with no-arg consturctor... but it's not elegant.

2) If I do settle for @AnalyzerDef, does it have be be declared on a specific Entity?
What if I want this analyzer to be shared for all entities?

Thanks very much :)


Top
 Profile  
 
 Post subject: Re: hibernate search - analyzer instantiation?
PostPosted: Tue May 03, 2011 5:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Quote:
1) I wanted to invoke the parametrized constructor: new SnowballAnalyzer(version, name).
I couldn't find an elegant way to do it...
@Analyzer(impl=classname) doesn't receive constructor parameters.
@AnalyzerDef works, but the examples I see are cumbersome:
Code:
@AnalyzerDefname="englishSnowball",tokenizer =
      @TokenizerDef(factory = StandardTokenizerFactory.class ),
           filters = {@TokenFilterDef(factory=StandardFilterFactory.class),
                        @TokenFilterDef(factory=LowerCaseFilterFactory.class),
                        @TokenFilterDef(factory = StopFilterFactory.class...
       @TokenFilterDef(factory = SnowballPorterFilterFactory.class,
              params = @Parameter(name="language", value="English") )

While I just wanted simple the defaults of SnowballAnalyzer... Is there no elegant way for hibernate search to invoke a parametrized constructor?
Of course I can wrap SnowballAnalyzer with my own Analyzer, with no-arg consturctor... but it's not elegant.

What's elegant? Do you have something in mind. Using @AnalyzerDefname is there to allow you to configure your analyzers via annotations in a generic form (including passing parameters). If you have some better ideas let us know.

Quote:
2) If I do settle for @AnalyzerDef, does it have be be declared on a specific Entity?
What if I want this analyzer to be shared for all entities?

No, analyzer definitions are global. You can define it on any entity and use it from any


Top
 Profile  
 
 Post subject: Re: hibernate search - analyzer instantiation?
PostPosted: Tue May 03, 2011 9:30 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Thanks, and no offense meant - I deeply appreciate the design of hibernate search, and learned a lot from it :)

I just wonder why @AnalyzerDef forces me to dive into the "Filters" level... sometimes I need such control, but sometimes I just want "new SnowballAnalyzer(version, name)"... this constructor was provided exactly so that users can get started with reasonable defaults, without having to wonder "Should StopWords be filtered before or after Lowercase conversion? Have I forgotten anything else?"...

I would have been glad to (also) have the option to call parametrized constructors (or factory methods), something in the lines of
@Analyzer (impl="SnowballAnalyzer" params={Version.30, "English"})

Thanks anyway.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.