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 George <em...@gmail.com> on 2008/11/02 10:09:49 UTC

Custom sort (score + custom value)

Hi,

I want to implement a custom sort in Solr based on a combination of
relevance (Solr gives me it yet => score) and a custom value I've calculated
previously for each document. I see two options:

1. Use a function query (I'm using a DisMaxRequestHandler).
2. Create a component that set SortSpec with a sort that has a custom
ComparatorSource (similar to QueryElevationComponent).

The first option has the problem: While the relevance value changes for
every query, my custom value is constant for each doc. It implies queries
with documents that have high relevance are less affected with my custom
value. On the other hand, queries with low relevance are affected a lot with
my custom value. Can it be proportional with a function query? (i.e. docs
with low relevance are less affected by my custom value).

The second option has the problem: Solr score isn't normalized. I need it
normalized in order to apply my custom value in the sortValue function in
ScoreDocComparator.

What do you think? What's the best option in that case? Another option?

Thank you in advance,

George

Re: Custom sort (score + custom value)

Posted by George <em...@gmail.com>.
Todd: Yes, I looked into these arguments before I found the problem I
described in the first email.

Yonik: It's exactly what I was looking for.

George

On Mon, Nov 3, 2008 at 7:10 PM, Yonik Seeley <yo...@apache.org> wrote:

> On Mon, Nov 3, 2008 at 12:37 PM, George <em...@gmail.com> wrote:
> > Ok Yonik, thank you.
> >
> > I've tried to execute the following query: "{!boost b=log(myrank)
> > defType=dismax}q" and it works great.
> >
> > Do you know if I can do the same (combine a DisjunctionMaxQuery with a
> > BoostedQuery) in solrconfig.xml?
>
> Do you mean set it as a default for a handler in solrconfig.xml?  That
> should work.
> You could set a default of q={!boost b=log(myrank) defType=dismax v=$uq}
> then all the client would have to pass in is uq (the user query)
>
> -Yonik
>

Re: Custom sort (score + custom value)

Posted by Yonik Seeley <yo...@apache.org>.
On Mon, Nov 3, 2008 at 12:37 PM, George <em...@gmail.com> wrote:
> Ok Yonik, thank you.
>
> I've tried to execute the following query: "{!boost b=log(myrank)
> defType=dismax}q" and it works great.
>
> Do you know if I can do the same (combine a DisjunctionMaxQuery with a
> BoostedQuery) in solrconfig.xml?

Do you mean set it as a default for a handler in solrconfig.xml?  That
should work.
You could set a default of q={!boost b=log(myrank) defType=dismax v=$uq}
then all the client would have to pass in is uq (the user query)

-Yonik

RE: Custom sort (score + custom value)

Posted by "Feak, Todd" <To...@smss.sony.com>.
Have you looked into the "bf" and "bq" arguments on the
DisMaxRequestHandler?

http://wiki.apache.org/solr/DisMaxRequestHandler?highlight=(dismax)#head
-6862070cf279d9a09bdab971309135c7aea22fb3

-Todd

-----Original Message-----
From: George [mailto:emagpada@gmail.com] 
Sent: Monday, November 03, 2008 9:38 AM
To: solr-user@lucene.apache.org
Subject: Re: Custom sort (score + custom value)

Ok Yonik, thank you.

I've tried to execute the following query: "{!boost b=log(myrank)
defType=dismax}q" and it works great.

Do you know if I can do the same (combine a DisjunctionMaxQuery with a
BoostedQuery) in solrconfig.xml?

George

On Sun, Nov 2, 2008 at 3:01 PM, Yonik Seeley <yo...@apache.org> wrote:

> On Sun, Nov 2, 2008 at 5:09 AM, George <em...@gmail.com> wrote:
> > I want to implement a custom sort in Solr based on a combination of
> > relevance (Solr gives me it yet => score) and a custom value I've
> calculated
> > previously for each document. I see two options:
> >
> > 1. Use a function query (I'm using a DisMaxRequestHandler).
> > 2. Create a component that set SortSpec with a sort that has a
custom
> > ComparatorSource (similar to QueryElevationComponent).
> >
> > The first option has the problem: While the relevance value changes
for
> > every query, my custom value is constant for each doc.
>
> Yes, that can be an issue when adding unrelated scores.
> Multiplying them might give you better results:
>
>
http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlu
gin.html
>
> -Yonik
>

Re: Custom sort (score + custom value)

Posted by George <em...@gmail.com>.
Ok Yonik, thank you.

I've tried to execute the following query: "{!boost b=log(myrank)
defType=dismax}q" and it works great.

Do you know if I can do the same (combine a DisjunctionMaxQuery with a
BoostedQuery) in solrconfig.xml?

George

On Sun, Nov 2, 2008 at 3:01 PM, Yonik Seeley <yo...@apache.org> wrote:

> On Sun, Nov 2, 2008 at 5:09 AM, George <em...@gmail.com> wrote:
> > I want to implement a custom sort in Solr based on a combination of
> > relevance (Solr gives me it yet => score) and a custom value I've
> calculated
> > previously for each document. I see two options:
> >
> > 1. Use a function query (I'm using a DisMaxRequestHandler).
> > 2. Create a component that set SortSpec with a sort that has a custom
> > ComparatorSource (similar to QueryElevationComponent).
> >
> > The first option has the problem: While the relevance value changes for
> > every query, my custom value is constant for each doc.
>
> Yes, that can be an issue when adding unrelated scores.
> Multiplying them might give you better results:
>
> http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlugin.html
>
> -Yonik
>

Re: Custom sort (score + custom value)

Posted by Yonik Seeley <yo...@apache.org>.
On Sun, Nov 2, 2008 at 5:09 AM, George <em...@gmail.com> wrote:
> I want to implement a custom sort in Solr based on a combination of
> relevance (Solr gives me it yet => score) and a custom value I've calculated
> previously for each document. I see two options:
>
> 1. Use a function query (I'm using a DisMaxRequestHandler).
> 2. Create a component that set SortSpec with a sort that has a custom
> ComparatorSource (similar to QueryElevationComponent).
>
> The first option has the problem: While the relevance value changes for
> every query, my custom value is constant for each doc.

Yes, that can be an issue when adding unrelated scores.
Multiplying them might give you better results:
http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlugin.html

-Yonik