You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Sébastien LAMAISON <yu...@hotmail.fr> on 2014/01/14 18:11:07 UTC

[SolR 3.0] Boost score by string position in field

Hi all,
I'm almost new to SolR, and I have to make a improvment on a existing project, but despite some hours of searching, I'm stuck.
We have an index containing products, which the user can search by reference, or name.By now, when the user make a search by product name, the score is the same for all products containing the search string in the name.
For example, if the search string is "TEST", the following products have the same score : - BLAHBLAH TEST BLAH- TEST BLAHBLAH- BLAHBLAHBLAHBLAHBLAHBLAH TEST
My question is : how can I make TEST BLAHBLAH have a better score than BLAHBLAH TEST BLAH have a better score than BLAHBLAHBLAHBLAHBLAHBLAH TEST if the user search "TEST" ?
Thanks in advance.
Seb 		 	   		  

Re: [SolR 3.0] Boost score by string position in field

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi Sebastien,

I think you want to boost product names that start with query term, right? Or in other words, boost if query term occurs within the first N words of a document.

SpanFirstQuery seems an elegant way to do it. https://issues.apache.org/jira/browse/SOLR-3925

Alternatively one can add an artificial token at the beginning of text. 

someArtificialToken TEST BLAHBLAH 


and use a phrase query to boost : "someArtificialToken queryTerm"~N

Ahmet
On Tuesday, January 14, 2014 7:13 PM, Sébastien LAMAISON <yu...@hotmail.fr> wrote:
Hi all,
I'm almost new to SolR, and I have to make a improvment on a existing project, but despite some hours of searching, I'm stuck.
We have an index containing products, which the user can search by reference, or name.By now, when the user make a search by product name, the score is the same for all products containing the search string in the name.
For example, if the search string is "TEST", the following products have the same score : - BLAHBLAH TEST BLAH- TEST BLAHBLAH- BLAHBLAHBLAHBLAHBLAHBLAH TEST
My question is : how can I make TEST BLAHBLAH have a better score than BLAHBLAH TEST BLAH have a better score than BLAHBLAHBLAHBLAHBLAHBLAH TEST if the user search "TEST" ?
Thanks in advance.
Seb                           

Re: [SolR 3.0] Boost score by string position in field

Posted by Erick Erickson <er...@gmail.com>.
It's usually a mistake to try to tune at this level. The tf/idf
calculations _already_ take into account the field length (measured in
tokens) when scoring. Matches on shorter fields add more to the score
than matches on longer fields, which seems to be what you're looking
for.

That said, the length of the field is encoded and loses some precision
in order to save space (although I believe if memory serves you can
use higher precision lately). So Solr/Lucene will tend to think most
fields with, say, less n tokens are all the same length....

Very often, people spend lots of time chasing this down in artificial
test cases only to discover that when looking at real data, the
tweaking is unnecessary.

So I'm not really giving you any guidance to do what you asked, rather
I'm suggesting that you don't even try :)..

Best,
Erick

On Tue, Jan 14, 2014 at 12:11 PM, Sébastien LAMAISON <yu...@hotmail.fr> wrote:
> Hi all,
> I'm almost new to SolR, and I have to make a improvment on a existing project, but despite some hours of searching, I'm stuck.
> We have an index containing products, which the user can search by reference, or name.By now, when the user make a search by product name, the score is the same for all products containing the search string in the name.
> For example, if the search string is "TEST", the following products have the same score : - BLAHBLAH TEST BLAH- TEST BLAHBLAH- BLAHBLAHBLAHBLAHBLAHBLAH TEST
> My question is : how can I make TEST BLAHBLAH have a better score than BLAHBLAH TEST BLAH have a better score than BLAHBLAHBLAHBLAHBLAHBLAH TEST if the user search "TEST" ?
> Thanks in advance.
> Seb