To solve this issue I created a subclass of SortableIntField that overrides the 
getSortField() method as follows...

        @Override
        public SortField getSortField(SchemaField field, boolean reverse) {
                return new SortField(field.getName(), SortField.INT, reverse);
        }

I'm not really sure of the impact of this change but it seems to now do what I 
want. I'm curious as to why the SortableIntField supplied with SOLR uses 
SortField.STRING here. I found some references to it in solr-dev but no 
conclusions.

If anyone has any thoughts about the impact of this change, or why it is not 
like this by default I'd be very interested to hear.

Thanks,
Simon

-----Original Message-----
From: Simon Stanlake [mailto:sim...@tradebytes.com] 
Sent: Thursday, July 30, 2009 7:28 PM
To: 'solr-user@lucene.apache.org'
Subject: facet sorting by index on sint fields

Hi,
I have a field in my schema specified using

<field name="wordCount" type="sint"/>

Where "sint" is specified as follows (the default from schema.xml)

<fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" 
omitNorms="true"/>
    
When I do a facet on this field using sort=index I always get the values back 
in lexicographic order. Eg: adding this to a query string...

facet=true&facet.field=wordCount&f.wordCount.facet.sort=index

gives me
<lst name="wordCount">
        <int name="1">5</int>
        <int name="10">2</int>
        <int name="2">6</int>
...

Is this a current limitation of solr faceting or am I missing a configuration 
step somewhere? I couldn't find any notes in the docs about this.

Cheers,
Simon

Reply via email to