lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Sandiford <bob.sandif...@sirsidynix.com>
Subject RE: Natural string sorting
Date Fri, 29 Oct 2010 14:26:00 GMT
Well, you could do a magnitude notation approach.  Depends on how complex the strings are,
but based on your examples, this would work:

1) Identify a series of integers in the string.  (This assumes lengths are no more than 9
for each series).

2) Insert the number of integers into the string before the integer series itself

So - for sorting - you would have:

string1 --> string11
string10 --> string210
string2 --> string12

which will then sort as string11, string12, string210, but use the original strings as the
displays you want.

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com 

> -----Original Message-----
> From: Savvas-Andreas Moysidis
> [mailto:savvas.andreas.moysidis@googlemail.com]
> Sent: Friday, October 29, 2010 4:33 AM
> To: solr-user@lucene.apache.org
> Subject: Re: Natural string sorting
> 
> I think string10 is before string2 in lexicographic order?
> 
> On 29 October 2010 09:18, RL <rl.subscriber@gmail.com> wrote:
> 
> >
> > Just a quick question about natural sorting of strings.
> >
> > I've a simple dynamic field in my schema:
> >
> > <fieldType name="string" class="solr.StrField" sortMissingLast="true"
> > omitNorms="true"/>
> > <field name="nameSort_en" type="string" indexed="true" stored="false"
> > omitNorms="true"/>
> >
> > There are 3 indexed strings for example
> > string1,string2,string10
> >
> > Executing a query and sorting by this field leads to unnatural
> sorting of :
> > string1
> > string10
> > string2
> >
> > (Some time ago i used Lucene and i was pretty sure that Lucene used a
> > natural sort, thus i expected the same from solr)
> > Is there a way to sort in a natural order? Config option? Plugin?
> Expected
> > output would be:
> > string1
> > string2
> > string10
> >
> >
> > Thanks in advance.
> >
> >
> > --
> > View this message in context:
> > http://lucene.472066.n3.nabble.com/Natural-string-sorting-
> tp1791227p1791227.html
> > Sent from the Solr - User mailing list archive at Nabble.com.
> >

Mime
View raw message