-->
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: BoostStrategy for a Hashset field
PostPosted: Wed Mar 27, 2013 9:10 am 
Newbie

Joined: Wed Mar 27, 2013 8:56 am
Posts: 1
I have an @Entity User with a @Field that is a HashSet<User>.

I want to know the Document with the max number of users associated to boost with the formula in a CustomBoostStrategy:
Code:
boost = ( User.hashset / MaxNumberFromAnyUser.hashset ) x 0.25;

I canĀ“t Autowired any DAO.

Any help?

Thx :)


Top
 Profile  
 
 Post subject: Re: BoostStrategy for a Hashset field
PostPosted: Mon Apr 01, 2013 5:54 am 
Newbie

Joined: Wed Mar 13, 2013 8:41 am
Posts: 2
Hi all,

This is my first post in this forum, and I would first like to thank the whole team of Hibernate-Search for the great work done with this framework.

By reading this post I think @ veveloko has set a feature that I too may be interested. I think he wants to instantiate the class CustomBoosStrategy from Spring IoC container, in order to inject dependencies as a DAO class using the @Autowired, and finally this class is used by Hibernate-Search for calculating the Boost factor.

After analyzing source code I believe this integration with Spring beans is not possible, because the instantiation of BoosStrategy implementations classs is done by following method of AnnotationProcessinHelper class:

Code:
public static BoostStrategy getDynamicBoost(XProperty member) {
      DynamicBoost boostAnnotation = member.getAnnotation( DynamicBoost.class );
      if ( boostAnnotation == null ) {
         return DefaultBoostStrategy.INSTANCE;
      }

      Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
      BoostStrategy strategy;
      try {
         strategy = boostStrategyClass.newInstance();
      }
      catch ( Exception e ) {
         throw new SearchException(
               "Unable to instantiate boost strategy implementation: " + boostStrategyClass.getName()
         );
      }
      return strategy;
   }


Overall I would like to know if I can use Spring beans to create my implementations of Similarity, BoosStrategy, etc. ..


Thanks in advance, have a nice day
Antonio


Top
 Profile  
 
 Post subject: Re: BoostStrategy for a Hashset field
PostPosted: Wed Apr 03, 2013 7:08 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Antonio: you seem to have a more general question so let's discuss that in your other thread.

veveloko:

conceptually the problem is that while "MaxNumberFromAnyUser.hashset" might be a fixed number when you index this specific entity, the value might change after you save other entities. What would you want to happen in that case?
With such a solution you might need to rebuild the whole index at every database write, which is going to be extremely slow.

My advice is to use boosting at query time: you can affect the score on each document when running a query rather than write the boost score at index time.

See also org.apache.lucene.search.function.CustomScoreQuery

_________________
Sanne
http://in.relation.to/


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.