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 Benson Margulies <bi...@gmail.com> on 2012/03/21 15:21:27 UTC

Rescoring queries

I confess that I did only minimal googling before composing the below.

I would like to be able to insert my own code into Solr to rescore
query results. To be more specific, I'd like to send Solr a query in
which some additional information is attached to the query. After Solr
has done the usual query thing on the base query, I want to run code
of mine that rescores (and thus reorders) the results. In SolrCloud, I
want my 'improved' scores to be the ones used to create and order the
final result set.

Is there a place to put this sort of behavior in the architecture?

Re: Rescoring queries

Posted by Erick Erickson <er...@gmail.com>.
You probably want to provide a custom Similarity class. Here's
a start:
http://wiki.apache.org/solr/SolrPlugins#Similarity
That's just a brief hint, but it should get you started. From there
you'll have to  dig into the docs.


Do take some care here. I believe this is called for _every_ doc
that matches your query, so make sure what you do doesn't
take much time....

You might also be able to do what you want with function queries,
see: http://wiki.apache.org/solr/FunctionQuery, which you
can make a custom version of. The hint
is in the Using FunctionQuery section about ValueSourceParser
if the OOB function queries won't work.

BTW, it's quite possible you can get what you want without
going through this process, but unless you explain your
problem nobody can suggest any alternatives...


Best
Erick

On Wed, Mar 21, 2012 at 10:21 AM, Benson Margulies
<bi...@gmail.com> wrote:
> I confess that I did only minimal googling before composing the below.
>
> I would like to be able to insert my own code into Solr to rescore
> query results. To be more specific, I'd like to send Solr a query in
> which some additional information is attached to the query. After Solr
> has done the usual query thing on the base query, I want to run code
> of mine that rescores (and thus reorders) the results. In SolrCloud, I
> want my 'improved' scores to be the ones used to create and order the
> final result set.
>
> Is there a place to put this sort of behavior in the architecture?