-->
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.  [ 10 posts ] 
Author Message
 Post subject: How to tell HSearch, wich Analyzer to use for indexing
PostPosted: Fri Apr 27, 2007 9:40 am 
Newbie

Joined: Fri Apr 20, 2007 10:31 am
Posts: 10
I Couldn´t find a way to tell Hibernate Search, which Lucene-Analyzer to use for Indexcreating or Updating.

Therfore that we need our own Analyzer, that is a pitty.

I´m sure it´s possible, can someone tell me?

Thanks in advance and kind regards

einherier

EDIT:

I just edit this lines to the hibernate.cfg.xml :

<property name="hibernate.search.analyzer">
org.apache.lucene.analysis.standard.StandardAnalyzer
</property>

But I´m not sure if its working, since even at Debugloglevel, there isn´t told, which Analyzer was taken...

_________________
Meine Webseite (German):

Germanische Mythologie


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is no(t yet) specific log as far as I remember.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Right property
PostPosted: Thu May 03, 2007 6:10 pm 
Hibernate Team
Hibernate Team

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

hibernate.search.analyzer is the right property to use. You can specify only a single analyzer in this property. If working with Lucene directly you are more flexible on which analyzer to use for indexing/searching. In fact you can switch dynamically.

This is for example useful for multi national sites where you want to use a particular stemmer depending on a locale. When you write 'native' lucene code this is not a problem, but with the current Hibernate Search solution it is a little bit more difficult to solve.

The solution is to write your own analyzer my.company.Analyzer which you configure to be used via hibernate.search.analyzer. This custom analyzer can then eg use per field analyzing.

For the above example of switching the analyzer/stemmer depending on a local I choose to add the current locale to a ThreadLocal which my custom analyzer then can pick up. I am not sure if this is the best solution, but it works.

--hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 8:50 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Interesting, can you write it into the pattern section of the wiki.
I want to provide a per class analyzer (maybe per field, not sure it makes sense, query becomes harder to set up, comments welcome :-) ).

But I won't do a "dynamic" analyzer, so your solution makes perfect sense.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 9:47 am 
Newbie

Joined: Sun May 06, 2007 9:42 am
Posts: 7
Hi there,

I have a similar problem but a bit more complex.
I am trying to index company details. Each company has a country field.
I want to change the analyzer per record, determining the analyzer by the country value.
I don't mind doing this dynamically, but I have no clue if such a thing is possible.

Any thoughts would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 06, 2007 6:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I am not sure what you want to do is a "good thing". Did you have feedbacks from the Lucene community about that? It sounds bad to me, but I can't back it up.
As for implementing that, Hibernate Search would have to provide a way to use an Analyzer provider. Open an feature request if you still want to go that path.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 2:13 am 
Newbie

Joined: Sun May 06, 2007 9:42 am
Posts: 7
Hi emmanuel,

I have posted this question in the Lucene forum, here

Now as you can see I need to be able to index a stemmed and unstemmed field for each column of the company record, Using the correct analyzer for the stemmed field.

Any clue if I can implement this at the moment, or as you wrote before, I need to open a feature request for an Analyzer provider?

One more question, If I want to change the analyzer dynamically as mentioned above, when can I do it? I mean can I change the property value of hibernate.search.analyzer whenever I want or do I have to do it, on load of my spring context?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 11:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Indexing twice the same property poped up on my radar actually
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-45

There will be no dynamic change, just a provider handling the changes based on some context. open the jira issue we described earlier.

Another solution is to have a smart analyzer that recognize the language and adjust on demande, but that might not be simple

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Wiki page for customizing analyzers
PostPosted: Fri May 11, 2007 5:11 pm 
Hibernate Team
Hibernate Team

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

just created the following page on the hibernate wiki regarding customizing the lucene analyzer:

http://www.hibernate.org/419.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 10:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Thanks Hardy
I create an Hibernate Search community Area umbrella
and referenced your article here
http://www.hibernate.org/420.html

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.