You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Daxesh Parmar <da...@gmail.com> on 2025/03/04 12:24:32 UTC

Usage of functional sort

Hello,

We are using solr 9, we have a field id,
our use case is like this

If I have some ids to sort, suppose it has Id1, id2, id3, id4
The solr sorting should be id1 > id2 > id3 > id4 > any other documents in
solr.

We don't have a defining field that I can index and use the sorting
functionality.

I have tried using the eq function, where for the highest id I provide the
value as ListSize, then reducing it by 1.
*if(eq(id,"id1"),2,0) desc,**if(eq(id,"id2"),1,0) desc -> *this does not
work according to use case

is there a better approach then above or is there a way to merge these
different sorts into one sort?

Thanks in advance.

Re: Usage of functional sort

Posted by Daxesh Parmar <da...@gmail.com>.
thank you for the suggestion!

On Tue, 4 Mar 2025 at 18:46, Daxesh Parmar <da...@gmail.com>
wrote:

> I have tried it and its working fine in a single sort
>
> *if(eq(id,"id-1"),3,if(eq(id,"id-2"),2,if(eq(id,"id-1"),1,0))) desc*
>
> On Tue, 4 Mar 2025 at 18:02, ufuk yılmaz <uy...@vivaldi.net.invalid>
> wrote:
>
>> I haven’t tried but shouldn’t it be like
>>
>> if(eq(id,"id1"),2, if(eq(id,"id2"),1,0)) instead?
>>
>> —
>>
>> > On Mar 4, 2025, at 21:25, Daxesh Parmar <da...@gmail.com>
>> wrote:
>> > if(eq(id,"id1"),2,0)
>>
>>

Re: Usage of functional sort

Posted by Daxesh Parmar <da...@gmail.com>.
I have tried it and its working fine in a single sort

*if(eq(id,"id-1"),3,if(eq(id,"id-2"),2,if(eq(id,"id-1"),1,0))) desc*

On Tue, 4 Mar 2025 at 18:02, ufuk yılmaz <uy...@vivaldi.net.invalid>
wrote:

> I haven’t tried but shouldn’t it be like
>
> if(eq(id,"id1"),2, if(eq(id,"id2"),1,0)) instead?
>
> —
>
> > On Mar 4, 2025, at 21:25, Daxesh Parmar <da...@gmail.com>
> wrote:
> > if(eq(id,"id1"),2,0)
>
>

Re: Usage of functional sort

Posted by ufuk yılmaz <uy...@vivaldi.net.INVALID>.
I haven’t tried but shouldn’t it be like

if(eq(id,"id1"),2, if(eq(id,"id2"),1,0)) instead?

—

> On Mar 4, 2025, at 21:25, Daxesh Parmar <da...@gmail.com> wrote:
> if(eq(id,"id1"),2,0)