You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Sandeep Mestry <sa...@gmail.com> on 2013/05/13 12:02:42 UTC

Solr Sorting Algorithm

Good Morning All,

The alphabetical sorting is causing slight issues as below:

I have 3 documents with title value as below:

1) "Acer Palmatum (Tree)"
2) "Aceraceae (Tree Family)"
3) "Acer Pseudoplatanus (Tree)"

I have created title_sort field which is defined with field type as
alphaNumericalSort (that comes with solr example schema)

When I apply the sort order (sort=title_sort asc), I get the results as:

"Aceraceae (Tree Family)"
"Acer Palmatum (Tree)"
"Acer Pseudoplatanus (Tree)"

But, the expected order is (spaces first),

"Acer Palmatum (Tree)"
"Acer Pseudoplatanus (Tree)"
"Aceraceae (Tree Family)"

My unit test contains Collections.sort method and I get the expected
results but I'm not sure why Solr is doing it in different way.

>From Collections.sort API, I can see that it uses modified merge sort,
could you tell me which algorithm solr follows for sorting logic and also
if there is any other approach I can take?

Many Thanks,
Sandeep