Mailing List Archive

How to change sorting *after* getting search results
Hi Lucene community,

Our users could do very heavy searches and they are able to change the
sorting criteria multiple times after getting the results. We collect all
of them, this is important for our use case, disabling scoring if the
result size is too large to make the search faster. Currently we have our
own multi-thread sorting code using DocValues (one instance per thread) to
do this after the results are returned, so we don't have to run the heavy
searches again.

We are upgrading from Lucene 6.6 to 7.x and DocValues access is not random
anymore, but our custom sorting code was based on that. So we are
considering to stop using custom sorting and to use internal Lucene
sorting, but we need to change the sorting multiple times after getting the
TopDocs results. Is this possible? I searched the docs, but was just able
to find out how to sort at the same time the search is done using
IndexSearcher.search(..., Sort) methods.

Thanks in advance,
Luís Nassif
Re: How to change sorting *after* getting search results [ In reply to ]
I think you are asking how to re-sort a result set returned from
IndexSearcher.search, ie a TopDocs? You can do this with one of the various
Rescorers. Have you looked at those?

On Tue, Nov 30, 2021, 9:15 AM Luís Filipe Nassif <lfcnassif@gmail.com>
wrote:

> Hi Lucene community,
>
> Our users could do very heavy searches and they are able to change the
> sorting criteria multiple times after getting the results. We collect all
> of them, this is important for our use case, disabling scoring if the
> result size is too large to make the search faster. Currently we have our
> own multi-thread sorting code using DocValues (one instance per thread) to
> do this after the results are returned, so we don't have to run the heavy
> searches again.
>
> We are upgrading from Lucene 6.6 to 7.x and DocValues access is not random
> anymore, but our custom sorting code was based on that. So we are
> considering to stop using custom sorting and to use internal Lucene
> sorting, but we need to change the sorting multiple times after getting the
> TopDocs results. Is this possible? I searched the docs, but was just able
> to find out how to sort at the same time the search is done using
> IndexSearcher.search(..., Sort) methods.
>
> Thanks in advance,
> Luís Nassif
>
Re: How to change sorting *after* getting search results [ In reply to ]
No, I didn't know about them, SortRescorer should do the job.

Thank you, Michael!
Luís

Em ter., 30 de nov. de 2021 às 15:24, Michael Sokolov <msokolov@gmail.com>
escreveu:

> I think you are asking how to re-sort a result set returned from
> IndexSearcher.search, ie a TopDocs? You can do this with one of the various
> Rescorers. Have you looked at those?
>
> On Tue, Nov 30, 2021, 9:15 AM Luís Filipe Nassif <lfcnassif@gmail.com>
> wrote:
>
>> Hi Lucene community,
>>
>> Our users could do very heavy searches and they are able to change the
>> sorting criteria multiple times after getting the results. We collect all
>> of them, this is important for our use case, disabling scoring if the
>> result size is too large to make the search faster. Currently we have our
>> own multi-thread sorting code using DocValues (one instance per thread) to
>> do this after the results are returned, so we don't have to run the heavy
>> searches again.
>>
>> We are upgrading from Lucene 6.6 to 7.x and DocValues access is not random
>> anymore, but our custom sorting code was based on that. So we are
>> considering to stop using custom sorting and to use internal Lucene
>> sorting, but we need to change the sorting multiple times after getting
>> the
>> TopDocs results. Is this possible? I searched the docs, but was just able
>> to find out how to sort at the same time the search is done using
>> IndexSearcher.search(..., Sort) methods.
>>
>> Thanks in advance,
>> Luís Nassif
>>
>