Murugesan Palanivel
Murugesan Palanivel

Reputation: 168

Solr Facet Index Sorting not working for numerics

I'm using Solr for offering faceted autosuggestion.I'm using latest version of Solr.

Here is an example what I need to do.

The suggestion order should be

grade 1
grade 2
grade 3
grade 4
...
...
grade 10

But now it look like this...
grade 1
grade 10
grade 11
grade 12
grade 2
grade 3
...
...

I am using facet.sort=index .
Any idea how to do this??Please advise..

Upvotes: 1

Views: 223

Answers (2)

jfchen
jfchen

Reputation: 21

Word 'grade' is useless to index. If you index the actual numeric grade, e.g., 1,2,3,...,10, then you can sort it. And if you make its type double, by default it is sorted numerically. Like the example below:

/select?q=*%3A*&fq=ZIP_code%3D94602&fq=Year%3A[1999+TO+2013]&fq=NOT+Causes_of_Death:OTH&fl=Year,Causes_of_Death,Count&wt=csv&indent=true&rows=200&sort=Count+desc

Year,Causes_of_Death,Count 2000,HTD,68 2002,HTD,64 1999,CAN,61 1999,HTD,60 2005,CAN,60 2001,CAN,57

Hope this helps.

Upvotes: 0

Toke Eskildsen
Toke Eskildsen

Reputation: 729

Index as 001, 002, 003, ... 999 and remove the leading zeroes in your front end.

Upvotes: 1

Related Questions