Santhosh Sheshasayanan <ss00115...@techmahindra.com> wrote:
> When I do range search on the "version" field with criteria
> [* TO 2.5.0.5], it gave me all the value like (2.5.0.1, 2.5.0.10,
> 2.5.0.4). But this is wrong result. Since I was expecting only
> 2.5.0.1 and 2.5.0.4.
> But it include 2.5.0.10 with the results. I googled and found
> that solr does lexical sorting. But I want numerical sorting.

Numbers in Solr-land are either integers or floating point values. From hat 
perspective, '2.5.0.10' it just ciphers delimited by dots. You want a special 
sort that handles versioning designations. As far as I know that is not 
supported by Solr, so you will have to roll your own.

The simplest solution is to pad with zeroes, so '2.5.0.4' becomes 
'002005000004', '2.5.0.10' becomes '002005000010', and '2.5.0' becomes 
'002005000000', which sorts lexically as you want.

You will have to make your padding conservative enough to cover all your 
versioning cases. Remember to consider 'alpha', 'beta', 'SNAPSHOT' and similar 
postfixes.


- Toke Eskildsen

Reply via email to