You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by "Kien, Theo" <Th...@bis.org.INVALID> on 2021/10/04 08:15:00 UTC

Sorting by float field, ignoring NaN

Dear users

Does anybody know how to sort search results by a float field (using Solr version 8.9), but having documents that have NaN for this field always appear last?
Currently, when sorting by the float field in DESC order, the values NaN appear at the top. I'd like to have these appear always at the bottom, independent of the sorting ASC or DESC.

I have tried to sort with "if" or "map", but can't get the Boolean expression to match NaN.

Any help appreciated.
Thanks
Theo


Disclaimer

This e-mail message and any attachments (“message”) may contain confidential, privileged or proprietary information and is intended solely for the use of the named recipient(s). If you are not the intended recipient, you may not disclose, copy, distribute or retain any part of this message. If you have received this message in error, please inform the sender immediately by return e-mail and delete this message from your system. The BIS is not liable for any error in the content of this message and does not represent that it is uncorrupted and/or free of viruses. Views expressed in this message are those of the author and may not reflect those of the BIS.

By exchanging e-mails with the BIS it is understood that the BIS may collect, store and further use e-mail addresses and other personal information which may be provided therein. The BIS will treat such information as confidential.

Re: Sorting by float field, ignoring NaN

Posted by Matthew Lapointe <ml...@alpha-sense.com>.
Hi Theo,

You could try something like if(eq(div(0,0),field),-1,field), though
there's probably a more elegant way to do it

Matt


On Mon, Oct 4, 2021 at 1:46 PM Pinkesh Sharma <pi...@gmail.com>
wrote:

> you can try updating the field type to include sort missing first and last
>
> sortMissingLast="true" sortMissingFirst="false"
>
>
> On Mon, Oct 4, 2021 at 4:15 AM Kien, Theo <Th...@bis.org.invalid>
> wrote:
>
> > Dear users
> >
> > Does anybody know how to sort search results by a float field (using Solr
> > version 8.9), but having documents that have NaN for this field always
> > appear last?
> > Currently, when sorting by the float field in DESC order, the values NaN
> > appear at the top. I'd like to have these appear always at the bottom,
> > independent of the sorting ASC or DESC.
> >
> > I have tried to sort with "if" or "map", but can't get the Boolean
> > expression to match NaN.
> >
> > Any help appreciated.
> > Thanks
> > Theo
> >
> >
> > Disclaimer
> >
> > This e-mail message and any attachments (“message”) may contain
> > confidential, privileged or proprietary information and is intended
> solely
> > for the use of the named recipient(s). If you are not the intended
> > recipient, you may not disclose, copy, distribute or retain any part of
> > this message. If you have received this message in error, please inform
> the
> > sender immediately by return e-mail and delete this message from your
> > system. The BIS is not liable for any error in the content of this
> message
> > and does not represent that it is uncorrupted and/or free of viruses.
> Views
> > expressed in this message are those of the author and may not reflect
> those
> > of the BIS.
> >
> > By exchanging e-mails with the BIS it is understood that the BIS may
> > collect, store and further use e-mail addresses and other personal
> > information which may be provided therein. The BIS will treat such
> > information as confidential.
> >
>
>
> --
> Regards:
> Pinkesh Sharma
>

Re: Sorting by float field, ignoring NaN

Posted by Pinkesh Sharma <pi...@gmail.com>.
you can try updating the field type to include sort missing first and last

sortMissingLast="true" sortMissingFirst="false"


On Mon, Oct 4, 2021 at 4:15 AM Kien, Theo <Th...@bis.org.invalid> wrote:

> Dear users
>
> Does anybody know how to sort search results by a float field (using Solr
> version 8.9), but having documents that have NaN for this field always
> appear last?
> Currently, when sorting by the float field in DESC order, the values NaN
> appear at the top. I'd like to have these appear always at the bottom,
> independent of the sorting ASC or DESC.
>
> I have tried to sort with "if" or "map", but can't get the Boolean
> expression to match NaN.
>
> Any help appreciated.
> Thanks
> Theo
>
>
> Disclaimer
>
> This e-mail message and any attachments (“message”) may contain
> confidential, privileged or proprietary information and is intended solely
> for the use of the named recipient(s). If you are not the intended
> recipient, you may not disclose, copy, distribute or retain any part of
> this message. If you have received this message in error, please inform the
> sender immediately by return e-mail and delete this message from your
> system. The BIS is not liable for any error in the content of this message
> and does not represent that it is uncorrupted and/or free of viruses. Views
> expressed in this message are those of the author and may not reflect those
> of the BIS.
>
> By exchanging e-mails with the BIS it is understood that the BIS may
> collect, store and further use e-mail addresses and other personal
> information which may be provided therein. The BIS will treat such
> information as confidential.
>


-- 
Regards:
Pinkesh Sharma