You're right, it would be better to just give it a sortable numerical value. 
For now I gave time_code a sdouble type and see if it sorted, and it did. 
However all the 0's are trimmed, but that shouldn't be a problem unless it were 
to truncate any values past the hundreds column.

Thanks.
- Noel

-----Original Message-----
From: "Jan Høydahl / Cominvent" <jan....@cominvent.com>
Sent: Monday, September 13, 2010 5:31am
To: solr-user@lucene.apache.org
Subject: Re: Sorting not working on a string field

Hi,

May you show us what result you actually get? Wouldn't it make more sense to 
choose a numeric fieldtype? To get proper sort order of numbers in a string 
field, all number need to be exactly same length since order will be 
lexiographical, i.e. "10" will come before "2", but after "02".

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

On 10. sep. 2010, at 19.14, n...@frameweld.com wrote:

> Hello, I seem to be having a problem with sorting. I have a string field 
> (time_code) that I want to order by. When the results come up, it displays 
> the results differently from relevance which I would assume, but the results 
> aren't ordered. The data in time_code came from a numeric decimal with a six 
> digit precision if that makes a difference(ex: 1.000000).
> 
> Here is the query I give it:
> 
> q=ceremony+AND+presentation_id%3A296+AND+type%3Ablob&version=1.3&json.nl=map&rows=100000&start=0&wt=json&hl=true&hl.fl=text&hl.simple.pre=<span+class%3D"hl">&hl.simple.post=<%2Fspan>&hl.fragsize=0&hl.mergeContiguous=false&&sort=time_code+asc
> 
> 
> And here's the field schema:
> 
> <field name="presentation_id" type="sint" indexed="true" stored="true"/>
> <field name="asset_id" type="sint" indexed="true" stored="true"/>
> <field name="type" type="text" indexed="true" stored="true"/>
> <field name="text" type="text" indexed="true" stored="true" 
> multiValued="true"/>
> <field name="time_code" type="string" indexed="true" stored="true"/>
> <field name="unique_key" type="string" indexed="true" stored="true"/>
> <dynamicField name="*" type="text" indexed="true" stored="true"/>
> <field name="all_text" type="text" indexed="true" stored="true" 
> allowDups="true" multiValued="true"/>
> <copyField source="*" dest="all_text"/>
> <field name="text_dup" type="textSpell" indexed="true" stored="true" 
> allowDups="true"/>
> <copyField source="text" dest="text_dup"/>
> 
> Thanks for any help.
> 



Reply via email to