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 "Fornoville, Tom" <To...@truvo.com> on 2010/06/09 15:35:29 UTC
custom scorer in Solr
Hi all,
We are currently working on a proof-of-concept for a client using Solr
and have been able to configure all the features they want except the
scoring.
Problem is that they want scores that make results fall in buckets:
* Bucket 1: exact match on category (score = 4)
* Bucket 2: exact match on name (score = 3)
* Bucket 3: partial match on category (score = 2)
* Bucket 4: partial match on name (score = 1)
First thing we did was develop a custom similarity class that would
return the correct score depending on the field and an exact or partial
match.
The only problem now is that when a document matches on both the
category and name the scores are added together.
Example: searching for "restaurant" returns documents in the category
restaurant that also have the word restaurant in their name and thus get
a score of 5 (4+1) but they should only get 4.
I assume for this to work we would need to develop a custom Scorer class
but we have no clue on how to incorporate this in Solr.
Maybe there is even a simpler solution that we don't know about.
All suggestions welcome!
Thanks,
Tom
Re: custom scorer in Solr
Posted by Chris Hostetter <ho...@fucit.org>.
: Problem is that they want scores that make results fall in buckets:
:
: * Bucket 1: exact match on category (score = 4)
: * Bucket 2: exact match on name (score = 3)
: * Bucket 3: partial match on category (score = 2)
: * Bucket 4: partial match on name (score = 1)
...
: First thing we did was develop a custom similarity class that would
: return the correct score depending on the field and an exact or partial
: match.
...
: The only problem now is that when a document matches on both the
: category and name the scores are added together.
what QParser are you using? what does the resulting Query data structure
look like?
I think with your custom Similarity class you might be able to achieve
your goal using the DisMaxQParser w/o any other custom code -- just set
your "qf=category name" (i'm assuming your Similarity already handles the
relative weighting) and set the "tie=0" ... that will ensure that the
final score only comes from the "Max" scoring field (ie: no tie breaking
values fro mthe other fields)
if thta doesn't do what you want -- then your best bet is probably to
write a custom QParser that generates *exactly* the query structure you
want (likely using a DisjunctionMaxQuery) thta will give you the scores
you want in conjunction with your similarity class.
-Hoss