You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by po...@gmail.com on 2021/08/29 18:09:43 UTC
Sort results based on alpha at first
Hi,
We need to sort the results based on alphabetic followed by numeric.
Something like below
Current results order:
1test
2test
3test
Abctext
Bbctext
Cbctext
Expected results order:
Abctext
Bbctext
Cbctext
1test
2test
3test
Please help me to achieve the result ordering as above.
Thanks,
Thamizh
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Re: Sort results based on alpha at first
Posted by Thomas Corthals <th...@klascement.net>.
Hi Thamizh
You can add a field to the index that acts as a "sortable flag" with e.g. 0
for alpha, 1 for numerical, and 2 for other first character. Then you can
sort on both fields, listing the "flag" field first.
Thomas
Op zo 29 aug. 2021 20:09 schreef <po...@gmail.com>:
> Hi,
>
>
>
> We need to sort the results based on alphabetic followed by numeric.
> Something like below
>
>
>
> Current results order:
>
> 1test
>
> 2test
>
> 3test
>
> Abctext
>
> Bbctext
>
> Cbctext
>
>
>
> Expected results order:
>
> Abctext
>
> Bbctext
>
> Cbctext
>
> 1test
>
> 2test
>
> 3test
>
>
>
> Please help me to achieve the result ordering as above.
>
>
>
> Thanks,
>
> Thamizh
>
>
>
> --
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
Re: Sort results based on alpha at first
Posted by Shawn Heisey <ap...@elyograg.org>.
On 8/29/2021 12:09 PM, post.tamil@gmail.com wrote:
> We need to sort the results based on alphabetic followed by numeric.
> Something like below
<snip>
> Expected results order:
> Abctext
> Bbctext
> Cbctext
> 1test
> 2test
> 3test
This is contrary to all the "natural" sort ordering available in modern
programming languages. In the ASCII table, numbers come before letters.
Though one may exist, I have never heard about anything to do this in
Java.
You would have to write (or find) custom sorting code to achieve this.
And then somehow get it integrated into Solr ... and I have no idea how
to integrate custom sorting algorithms.
Alternatively, you could return more results than the user actually asks
for, sorted some other way like relevancy score, and then do the sort
yourself in the client code (like a webapp).
Thanks,
Shawn