-->
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 - Multiple Analyzer
PostPosted: Fri Jan 23, 2009 1:36 am 
Newbie

Joined: Tue Jan 20, 2009 12:55 pm
Posts: 5
Hi,

I am using Hibernate Search for performing search. I have a JPA/Hibernate entity say 'Inventory' which gets indexed whenever the entity changes (I use hibernate annotations for indexing). My requirement is that, for some of the attributes of Inventory say 'vehicle color', I want to implement Synonym as well as Metaphone(Soundex). I have corresponding analyzers which works perfectly fine if I use one analyzer at a time (I understand that only one analyzeris allowed for an entity attribute). My question is how can I enable both sysnonym and metaphone search for this field.

Any help in this regard would be highly appreciated.

Thanks,
Deepa[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 6:18 am 
Hibernate Team
Hibernate Team

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

really there are several options here.

1. You just index your attribute twice using the @Fields annotations containing two @Field annotations each with its own analyzer (@Field has a 'analyzer' attribute).

2. You write your own custom analyzer. If you look at the implementation of a Analyzer you will see that all it does is to define an initial tokenizer (often the StandardTokenizer), followed by a chain of TokenFilters doing additional operations like adding synonyms to the token stream and/or adding soundex tokens. All your custom analyzer would have to do is create the right chain of filters. Probably you want to first insert synonyms and then even create soundex tokens for these synonyms.

3. You can use the @AnalyzerDef framework of HibernateSearch and define your tokenizers and filters declarative. Have a look at the online documentation of Hibernate Search. @AnalyzerDef depends on the Solr analyzer framework which uses a factory pattern to instantiate the right analyzer. In fact there is SynonymFilter and a PhoneticFilter available in the Solr framework. Maybe you can use them? The Hibernate Search codebase contains some tests using these two filters in case you are looking for some examples.

If I understand your usecase correctly I would recommend option 2 or 3.
I hope this helped.

--Hardy


Top
 Profile  
 
 Post subject: Hibernate Search - Multiple Analyzer
PostPosted: Fri Jan 30, 2009 4:07 am 
Newbie

Joined: Tue Jan 20, 2009 12:55 pm
Posts: 5
Thanks Hardy. I tried writing a custom analyzer with a chain of desired filters. This works well. Thanks for the pointer.

Regards,
Deepa


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.