How to achieve custom sorting while querying

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to achieve custom sorting while querying

padmanabhan
This post was updated on .
Hello Solr Geeks,

Am newbie to SOLR. I have a requirement as given below, Could any one please provide some insights on how to go about on this.

"Ascending by name" (#, 0 - 9, A - Z)

"Descending by name" (Z - A, 9 - 0, #)

Sample name value can be

ABCD5678
1234ABCD
#2345ABCD
#1234ABCD
5678ABCD
#2345ACBD
5678EFGH
#2345DBCA
ABCD1234
1234#ABCD

Expected Ascending order

#2345ABCD
#2345ACBD
#2345DBCA
1234#ABCD
1234ABCD
5678ABCD
ABCD1234
ABCD5678

Expected Descending order

ABCD5678
ABCD1234
5678ABCD
1234ABCD
1234#ABCD
#2345DBCA
#2345ACBD
#2345ABCD

Thanks & Regards,
Paddy
Reply | Threaded
Open this post in threaded view
|

Re: Custom Sort option to apply at SOLR index

Erick Erickson
I guess I don't see the problem, just store it as a string and sort on
the field.

# sorts before numbers which sort before characters. Or I'm reading
the ASCII chart wrong.

Best,
Erick

On Wed, Aug 2, 2017 at 6:55 AM, padmanabhan
<[hidden email]> wrote:

> Hello Solr Geeks,
>
> Am newbie to SOLR. I have a requirement as given below, Could any one please
> provide some insights on how to go about on this.
>
> "Ascending by name" (#, 0 - 9, A - Z)
>
> "Descending by name" (Z - A, 9 - 0, #)
>
> Sample name value can be
>
> ABCD5678
> 1234ABCD
> #2345ABCD
> #1234ABCD
> 5678ABCD
> #2345ACBD
> 5678EFGH
> #2345DBCA
> ABCD1234
> 1234#ABCD
>
> *Expected Ascending order*
>
> #2345ABCD
> #2345ACBD
> #2345DBCA
> 1234#ABCD
> 1234ABCD
> 5678ABCD
> ABCD1234
> ABCD5678
>
> *Expected Descending order*
>
> ABCD5678
> ABCD1234
> 5678ABCD
> 1234ABCD
> 1234#ABCD
> #2345DBCA
> #2345ACBD
> #2345ABCD
>
> Thanks & Regards,
> Paddy
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Custom-Sort-option-to-apply-at-SOLR-index-tp4348787.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Custom Sort option to apply at SOLR index

padmanabhan
Thank you Erick, it worked.



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html