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 Bojan Šmid <bo...@gmail.com> on 2009/10/02 15:12:48 UTC
conditional sorting
Hi all,
I need to perform sorting of my query hits by different criterion depending
on the number of hits. For instance, if there are < 10 hits, sort by
date_entered, otherwise, sort by popularity.
Does anyone know if there is a way to do that with a single query, or I'll
have to send another query with desired sort criterion after I inspect
number of hits on my client?
Thx
Re: conditional sorting
Posted by Lance Norskog <go...@gmail.com>.
Doing a second search immediately after the first one is consistently
under 100 ms for me, usually under 25, on cheap hardware. Even while
sorting the results, you should have no problems. If necessary, you
could run Solr with the embedded client and do one search right after
the other, avoid the thread-switching that can happen between HTTP
requests.
On Fri, Oct 2, 2009 at 8:15 AM, Bojan Šmid <bo...@gmail.com> wrote:
> I tried to simplify the problem, but the point is that I could have really
> complex requirements. For instance, "if in the first 5 results none are
> older than one year, use sort by X, otherwise sort by Y".
>
> So, the question is, is there a way to make Solr recognize complex
> situations and apply different sorting criterion.
>
> Bojan
>
>
> On Fri, Oct 2, 2009 at 4:22 PM, Uri Boness <ub...@gmail.com> wrote:
>
>> If the threshold is only 10, why can't you always sort by popularity and if
>> the result set is <10 then resort on the client side based on date_entered?
>>
>> Uri
>>
>>
>> Bojan Šmid wrote:
>>
>>> Hi all,
>>>
>>> I need to perform sorting of my query hits by different criterion
>>> depending
>>> on the number of hits. For instance, if there are < 10 hits, sort by
>>> date_entered, otherwise, sort by popularity.
>>>
>>> Does anyone know if there is a way to do that with a single query, or I'll
>>> have to send another query with desired sort criterion after I inspect
>>> number of hits on my client?
>>>
>>> Thx
>>>
>>>
>>>
>>
>
--
Lance Norskog
goksron@gmail.com
Re: conditional sorting
Posted by Chris Hostetter <ho...@fucit.org>.
: I tried to simplify the problem, but the point is that I could have
: really: complex requirements. For instance, "if in the first 5 results
: none are older than one year, use sort by X, otherwise sort by Y".
First 5 in what order? X? Y or something else?
: So, the question is, is there a way to make Solr recognize complex
: situations and apply different sorting criterion.
your question may seem simple to you, but unless you codify all the
examples of what you consider a "complex situation" and how you expect
those to be specified at run time, it's pretty much imposisble to give you
an answer as to what the best way to achieve your goal is.
the simplest answer based on the information available: if you can express
your requirements in java, and put them in a custom Search Component, then
Solr can do it.
-Hoss
Re: conditional sorting
Posted by Bojan Šmid <bo...@gmail.com>.
I tried to simplify the problem, but the point is that I could have really
complex requirements. For instance, "if in the first 5 results none are
older than one year, use sort by X, otherwise sort by Y".
So, the question is, is there a way to make Solr recognize complex
situations and apply different sorting criterion.
Bojan
On Fri, Oct 2, 2009 at 4:22 PM, Uri Boness <ub...@gmail.com> wrote:
> If the threshold is only 10, why can't you always sort by popularity and if
> the result set is <10 then resort on the client side based on date_entered?
>
> Uri
>
>
> Bojan Šmid wrote:
>
>> Hi all,
>>
>> I need to perform sorting of my query hits by different criterion
>> depending
>> on the number of hits. For instance, if there are < 10 hits, sort by
>> date_entered, otherwise, sort by popularity.
>>
>> Does anyone know if there is a way to do that with a single query, or I'll
>> have to send another query with desired sort criterion after I inspect
>> number of hits on my client?
>>
>> Thx
>>
>>
>>
>
Re: conditional sorting
Posted by Uri Boness <ub...@gmail.com>.
If the threshold is only 10, why can't you always sort by popularity and
if the result set is <10 then resort on the client side based on
date_entered?
Uri
Bojan Šmid wrote:
> Hi all,
>
> I need to perform sorting of my query hits by different criterion depending
> on the number of hits. For instance, if there are < 10 hits, sort by
> date_entered, otherwise, sort by popularity.
>
> Does anyone know if there is a way to do that with a single query, or I'll
> have to send another query with desired sort criterion after I inspect
> number of hits on my client?
>
> Thx
>
>