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 Naveen Pajjuri <pa...@myntra.com> on 2016/07/11 10:13:35 UTC

Sorting in solr

Hi,
If i apply some sorting order on solr. when are the Documents sorted.

   1. are documents sorted after fetching the results  ?
   2. or we get sorted documents ?

Regards,
Naveen

Re: Sorting in solr

Posted by Erick Erickson <er...@gmail.com>.
I'm going to be a bit pedantic here since
"before" and "after" are a little misleading. Perhaps
"during" is better.

What happens internally is that a list "rows" long
is kept (i..e the &rows=### parameter). Let's say
&rows=20. A list to hold 20 items is created. The
first 20 docs are just put in the list. After that, each
document is compared against the items in the list
and the new doc may replace one of the items
in the list.

Let's say you're sorting by an int asc. Let's say the
min value in the list is 10 and the max is 100.
Now, a new doc with a sort value of 110 comes in,
it shouldn't be returned so Solr just passes on.
Now a doc with a sort value of 9 comes in, it
is put in the list and the doc with 110 is removed.

So all the docs are examined, but only "rows" are
held in memory.

There are a series of refinements for SolrCloud and
the like, but that's out of scope.

Best,
Erick


On Mon, Jul 11, 2016 at 7:16 AM, Dheerendra Kulkarni
<dh...@gmail.com> wrote:
> Naveen,
>
> The documents are sorted before. Lets say if it was a post sort and you are
> fetching 10 rows it would have pulled up top 10 rows and sorted it. but
> that is not what happens in solr it sorts in all available docs as per the
> query and goves the number of rows as per your requirment.
>
> Regards,
> Dheerendra
>
> On Mon, Jul 11, 2016 at 6:59 PM, Sandeep Mestry <sa...@gmail.com> wrote:
>
>> Hi Naveen,
>>
>> I am not too sure what you're after but the sorting mechanism is applied
>> after search results are fetched.
>>
>> From Solr Ref Guide:
>>
>> https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-ThesortParameter
>>
>> The sort parameter *arranges search results* in either ascending (asc) or
>> descending (desc) order.
>>
>> Thanks,
>> Sandeep
>>
>> On 11 July 2016 at 11:13, Naveen Pajjuri <pa...@myntra.com> wrote:
>>
>> > Hi,
>> > If i apply some sorting order on solr. when are the Documents sorted.
>> >
>> >    1. are documents sorted after fetching the results  ?
>> >    2. or we get sorted documents ?
>> >
>> > Regards,
>> > Naveen
>> >
>>
>
>
>
> --
> Regards,
> Dheerendra

Re: Sorting in solr

Posted by Dheerendra Kulkarni <dh...@gmail.com>.
Naveen,

The documents are sorted before. Lets say if it was a post sort and you are
fetching 10 rows it would have pulled up top 10 rows and sorted it. but
that is not what happens in solr it sorts in all available docs as per the
query and goves the number of rows as per your requirment.

Regards,
Dheerendra

On Mon, Jul 11, 2016 at 6:59 PM, Sandeep Mestry <sa...@gmail.com> wrote:

> Hi Naveen,
>
> I am not too sure what you're after but the sorting mechanism is applied
> after search results are fetched.
>
> From Solr Ref Guide:
>
> https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-ThesortParameter
>
> The sort parameter *arranges search results* in either ascending (asc) or
> descending (desc) order.
>
> Thanks,
> Sandeep
>
> On 11 July 2016 at 11:13, Naveen Pajjuri <pa...@myntra.com> wrote:
>
> > Hi,
> > If i apply some sorting order on solr. when are the Documents sorted.
> >
> >    1. are documents sorted after fetching the results  ?
> >    2. or we get sorted documents ?
> >
> > Regards,
> > Naveen
> >
>



-- 
Regards,
Dheerendra

Re: Sorting in solr

Posted by Sandeep Mestry <sa...@gmail.com>.
Hi Naveen,

I am not too sure what you're after but the sorting mechanism is applied
after search results are fetched.

From Solr Ref Guide:
https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-ThesortParameter

The sort parameter *arranges search results* in either ascending (asc) or
descending (desc) order.

Thanks,
Sandeep

On 11 July 2016 at 11:13, Naveen Pajjuri <pa...@myntra.com> wrote:

> Hi,
> If i apply some sorting order on solr. when are the Documents sorted.
>
>    1. are documents sorted after fetching the results  ?
>    2. or we get sorted documents ?
>
> Regards,
> Naveen
>