Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Change the default Analyzer StandardAnalyzer
PostPosted: Tue Dec 13, 2011 5:49 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
Hi All ,
my question is about changing the default Analyzer StandardAnalyzer in the configuration of Hibernate Search .I want that eliminate the @AnalzerDef from all my entites and use one analyzer (the new defaut one).
And Thx.


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 8:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you need to set the property _hibernate.search.analyzer_ to the fully qualified classname of your custom analyzer.


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 10:15 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
Hi Hardy and thx.
But u means the property in Hibernate.properties , right ??
and how can i create a custom analyzer which use a collection of the other analyzer ??
and thx to U Hardy.


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 10:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

in the properties file you can only specify a single analyzer class. If you want it to delegate to other analyzer you need a scoped analyzer (per field analyzer) which delegates to the appropriate analyzer based on the field name passed to the methods of the Analyzer interface. Have a look at the Hibernate Search internal class ScopedAnalyzer.

--Hardy


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 10:25 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
Thx Hardy.
how can i create a custom analyzer ??
for example
Code:
@AnalyzerDef(name = "simpleAnalyser", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {

        @TokenFilterDef(factory = StandardFilterFactory.class),
        @TokenFilterDef(factory = LowerCaseFilterFactory.class),
        @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = @Parameter(name = "language", value = "French"))
})

Thx :)


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 10:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you would have to programmatically wire together the analyzers. Look at the code for the different factories to get a feel how this is done. This is a fair bit of boiler plate code. For this reason we offer @AnalyzerDef. It just makes this process easier :-)

--Hardy


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 11:34 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
Do u have any idea how to wire them ??


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Wed Dec 14, 2011 11:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

look here - http://wiki.apache.org/lucene-java/Luce ... nalyzer.3F
Or even better look at these XYZFactory classes for example.
If you want all the gory details get hold of a copy of "Lucene in Action". Bottom line is that you have to understand how the analysis process works in Lucene and how tokenizers and filters work together.

--hardy


Top
 Profile  
 
 Post subject: Re: Change the default Analyzer StandardAnalyzer
PostPosted: Thu Dec 15, 2011 11:20 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
thank u very much Hardy for help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 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.