-->
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: Set boost value per object instance.
PostPosted: Wed Mar 17, 2010 10:43 pm 
Newbie

Joined: Tue May 31, 2005 11:19 pm
Posts: 11
Location: Brisbane, Australia
Hi,

I have a question on the @boost annotation.

First What I'm trying to achieve:
I have an indexed database full of products. Some products have more content and images against them than others and I want to slightly favour these products using a boost. I plan to put a float getBoost() method in my entity class which will return a higher number for these items.

As far as i understand the @boost annotation can be used in the following 2 places:
1) At class level - i believe that setting this will boost all instances of that class
2) At field level - this boosts a particular field within the class.

In my case all indexed items are the same class. I want to use boost to differentiate between individual items.
I believe this is possible because Lucene has a document.setBoost() method:
http://lucene.apache.org/java/2_3_0/api ... 28float%29

So my question is: is there an annotation to set a dynamic boost value per entity instance? Is there some way to use the @boost annotation that I've missed? (Can an annotation have a dynamic value?)

If not, my next step will be to dive into the Hibernate Search interceptors to achieve what I need by manually calling document.setBoot()

Thanks for any insight you can provide,

Brendan Richards.


Top
 Profile  
 
 Post subject: Re: Hibernate Search: Set boost value per object instance.
PostPosted: Thu Mar 18, 2010 2:42 pm 
Hibernate Team
Hibernate Team

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

what you are asking for is basically a dynamic boost. This feature is available in the latest beta version (3.2.0.Beta1) of Search. See HSEARCh-324

If you don't want to upgrade yet or are concerned about it being a beta, you could investigate using a ClassBridge. Using a class bridge you get a handle to the entity and the Lucene document. It is up to you and your usecase to make the best of it ;-)

Also, have you considered query time boosting?

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Search: Set boost value per object instance.
PostPosted: Thu Mar 18, 2010 7:00 pm 
Newbie

Joined: Tue May 31, 2005 11:19 pm
Posts: 11
Location: Brisbane, Australia
Hi,

Exactly what I'm looking for, thanks!

I actually spent some time yesterday hacking around with org.hibernate.search.engine.DocumentBuilderIndexedEntity and got the behavior I wanted but I think I'll switch to the Beta.
I only implemented a DynamicBoost at class level while it looks like the new feature allows Dynamic Boost for class, filelds and methods.

Thanks for the tip on ClassBridge. Next time i need to hack around that looks like a safer option!

As for query time boosting, in my particular use case the boost value is entirely dependent on the saved properties of the object instance so index-time boosting seems to be a better fit. I'm assuming that index-time boosting will be more performant.

Brendan


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.