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 Siping Liu <li...@gmail.com> on 2012/07/20 04:48:19 UTC

custom sorter

Hi,
I have requirements to place a document to a pre-determined  position for
special filter query values, for instance when filter query is
fq=(field1:"xyz") place document abc as first result (the rest of the
result set will be ordered by sort=field2). I guess I have to plug in my
Java code as a custom sorter. I'd appreciate it if someone can shed light
on this (how to add custom sorter, etc.)
TIA.

Re: custom sorter

Posted by Erick Erickson <er...@gmail.com>.
Wait.... by using filter queries with *:*, you're essentially
disabling scoring. *:*
resolves to ConstantScore Query, and filter queries don't lend any
scoring at all.

It really sounds like you're shooting yourself in the foot by using *:*, what
happens if you use q= instead? QEV can be used in this case.....

You can certainly define your own search component, but maybe you
can re-think the approach? Or is sorting _really_ the thing you want
to determine the results list, ignoring scoring all together?

Of course I may be completely off in the weeds.

Best
Erick

On Sun, Jul 22, 2012 at 10:59 AM, Siping Liu <li...@gmail.com> wrote:
> Hi -- thanks for the response. It's the right direction. However on closer
> look I don't think I can use it directly. The reason is that in my case,
> the query string is always "*:*", we use filter query to get different
> results. When fq=(field1:"xyz") we want to boost one document and let sort=
> to take care of the rest results, and when field1 has other value, sort=
> takes care of all results.
>
> Maybe I can define my own SearchComponent class, and specify it in
> <arr name="last-components">
>       <str>my_search_component</str>
>     </arr>
> I have to try and see if that'd work.
>
> thanks.
>
>
> On Fri, Jul 20, 2012 at 3:24 AM, Lee Carroll
> <le...@googlemail.com>wrote:
>
>> take a look at
>> http://wiki.apache.org/solr/QueryElevationComponent
>>
>> On 20 July 2012 03:48, Siping Liu <li...@gmail.com> wrote:
>>
>> > Hi,
>> > I have requirements to place a document to a pre-determined  position for
>> > special filter query values, for instance when filter query is
>> > fq=(field1:"xyz") place document abc as first result (the rest of the
>> > result set will be ordered by sort=field2). I guess I have to plug in my
>> > Java code as a custom sorter. I'd appreciate it if someone can shed light
>> > on this (how to add custom sorter, etc.)
>> > TIA.
>> >
>>

Re: custom sorter

Posted by Siping Liu <li...@gmail.com>.
Hi -- thanks for the response. It's the right direction. However on closer
look I don't think I can use it directly. The reason is that in my case,
the query string is always "*:*", we use filter query to get different
results. When fq=(field1:"xyz") we want to boost one document and let sort=
to take care of the rest results, and when field1 has other value, sort=
takes care of all results.

Maybe I can define my own SearchComponent class, and specify it in
<arr name="last-components">
      <str>my_search_component</str>
    </arr>
I have to try and see if that'd work.

thanks.


On Fri, Jul 20, 2012 at 3:24 AM, Lee Carroll
<le...@googlemail.com>wrote:

> take a look at
> http://wiki.apache.org/solr/QueryElevationComponent
>
> On 20 July 2012 03:48, Siping Liu <li...@gmail.com> wrote:
>
> > Hi,
> > I have requirements to place a document to a pre-determined  position for
> > special filter query values, for instance when filter query is
> > fq=(field1:"xyz") place document abc as first result (the rest of the
> > result set will be ordered by sort=field2). I guess I have to plug in my
> > Java code as a custom sorter. I'd appreciate it if someone can shed light
> > on this (how to add custom sorter, etc.)
> > TIA.
> >
>

Re: custom sorter

Posted by Lee Carroll <le...@googlemail.com>.
take a look at
http://wiki.apache.org/solr/QueryElevationComponent

On 20 July 2012 03:48, Siping Liu <li...@gmail.com> wrote:

> Hi,
> I have requirements to place a document to a pre-determined  position for
> special filter query values, for instance when filter query is
> fq=(field1:"xyz") place document abc as first result (the rest of the
> result set will be ordered by sort=field2). I guess I have to plug in my
> Java code as a custom sorter. I'd appreciate it if someone can shed light
> on this (how to add custom sorter, etc.)
> TIA.
>