-->
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.  [ 7 posts ] 
Author Message
 Post subject: Ranking Exact match results higher than partial matches
PostPosted: Tue Aug 27, 2013 1:49 am 
Newbie

Joined: Mon Dec 24, 2012 6:32 am
Posts: 17
Hi All,
I am using Hibernate Search for searching Customers ( columns -> first_name,last_name). User enters either of them and wildcard is appended to the each query term after tokenization.
I want the results with an exact match to the query to be scored and hence sorted higher in the results list. How can this be achieved ?

Thanks in advance,
Sourabh Ghorpade

_________________
Sourabh Ghorpade


Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Thu Aug 29, 2013 10:13 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

By default the results of wildcard searches have a constant score. You may give the recommendation from http://markmail.org/message/psgn7ag4ktld4za2 a try to change that. To access the scores of your query results, use ProjectionConstants.SCORE as described in the reference guide (http://docs.jboss.org/hibernate/search/4.4/reference/en-US/html_single/#d0e5630).

Hth,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Thu Aug 29, 2013 10:31 am 
Newbie

Joined: Mon Dec 24, 2012 6:32 am
Posts: 17
Gunnar wrote:
Hi,

By default the results of wildcard searches have a constant score. You may give the recommendation from http://markmail.org/message/psgn7ag4ktld4za2 a try to change that. To access the scores of your query results, use ProjectionConstants.SCORE as described in the reference guide (http://docs.jboss.org/hibernate/search/4.4/reference/en-US/html_single/#d0e5630).

Hth,

--Gunnar

Hi Gunnar,
Thanks for your reply. I will try the recommendation and post back. Just out of curiosity why cant we specify that exact matches should be given higher priority ?

_________________
Sourabh Ghorpade


Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Mon Sep 02, 2013 7:23 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
Gunnar is right on the scoring on wildcard queries; I would suggest to try a normal query without forcing it to be wildcard. In this case, the exact matches will always have an higher score than partial matches as that's the default strategy.
You can also run both queries, and combine them with the should operator: that will combine their score.

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


Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Tue Sep 17, 2013 7:11 am 
Newbie

Joined: Mon Dec 24, 2012 6:32 am
Posts: 17
sanne.grinovero wrote:
Hi,
Gunnar is right on the scoring on wildcard queries; I would suggest to try a normal query without forcing it to be wildcard. In this case, the exact matches will always have an higher score than partial matches as that's the default strategy.
You can also run both queries, and combine them with the should operator: that will combine their score.


Hi Sanne,
What I did was, the wildcard(*) is not added by default but by the user if required. So it works well if there is no wildcard, but same scenario occurs in-case of partial match. Is that what you were talking about ?

_________________
Sourabh Ghorpade


Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Wed Oct 09, 2013 12:26 pm 
Newbie

Joined: Mon Dec 24, 2012 6:32 am
Posts: 17
Gunnar wrote:
Hi,

By default the results of wildcard searches have a constant score. You may give the recommendation from http://markmail.org/message/psgn7ag4ktld4za2 a try to change that. To access the scores of your query results, use ProjectionConstants.SCORE as described in the reference guide (http://docs.jboss.org/hibernate/search/4.4/reference/en-US/html_single/#d0e5630).

Hth,

--Gunnar


Hi Gunnar, Sanne

I just tried that but now the partial matches are coming up on top instead of exact matches !
For Query "Gandalf*" , Search results are ->
Gandalfi Test M Test L
Gandalf Test M Test L
Gandalf Test M Test L

They should be the other way around. plain reverse sort wont help as we want only top 10 results, so exact matches might not even come up in top 10.
Sanne,
combining two queries won't help as now we are indexing the full name of a customer(first name + middle name + last name)
so a normal query will not give any results. so for above example just "gandalf" will not give any results.

_________________
Sourabh Ghorpade


Last edited by sourabh.ghorpade on Wed Oct 09, 2013 12:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Ranking Exact match results higher than partial matches
PostPosted: Wed Oct 09, 2013 12:43 pm 
Newbie

Joined: Mon Dec 24, 2012 6:32 am
Posts: 17
FOUND the solution! !!!
added a String sort to the full text Query on the customer name :D :D
nothing else required

_________________
Sourabh Ghorpade


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