-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dynamic boosting in Hibernate Search
PostPosted: Fri Feb 20, 2015 5:11 am 
Newbie

Joined: Thu Feb 19, 2015 10:23 am
Posts: 1
Hi All,

I need some help on dynamic boosting.
As per the documentation it works as below:

public enum PersonType {
NORMAL,
VIP
}
@Entity
@Indexed
@DynamicBoost(impl = VIPBoostStrategy.class)
public class Person {
private PersonType type;

// ...
}
public class VIPBoostStrategy implements BoostStrategy {
public float defineBoost(Object value) {
Person person = ( Person ) value;
if ( person.getType().equals( PersonType.VIP ) ) {
return 2.0f;
}
else {
return 1.0f;
}
}
}


I have some different requirement, I want to boost a field depending upon match("perfect match" or "partial match").
For Example consider I am searching for "India" on field called "country" and there are three matching records in the table with value of "country" field as follows:
1. India
2. Indiana
3. Indiana Town

Here I call 1 as "perfect match" and 2 ,3 as "partial match". For "perfect match" I want to give boost 2.0f and for "partial match" I want to give boost "1.5f".

Can somebody help in achieving this.
Any help will be appreciated.

Thanks,
Akash


Top
 Profile  
 
 Post subject: Re: Dynamic boosting in Hibernate Search
PostPosted: Tue Feb 24, 2015 8:47 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
considerations like that one are applied automatically, although the Lucene engine is going to be much smarter than your example as it will also consider how each term is actually relevant compared to the full set of terms in your index.

If you really want it to just use 1,5f and 2.0f exactly, then you should customize the Similarity implementation:
http://docs.jboss.org/hibernate/search/5.0/reference/en-US/html_single/#_customizing_lucene_s_scoring_formula

But before doing that, I would suggest to experiment with a full text query on your specific example using a projection on the EXPLANATION: it will print exactly which formula and which scores it will use for "India" vs "Indiana" vs "Indiana Town", etc..

See: FullTextQuery.EXPLANATION in http://docs.jboss.org/hibernate/search/5.0/reference/en-US/html_single/#projections

_________________
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.  [ 2 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.