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 Simon Stanlake <si...@tradebytes.com> on 2009/07/31 04:28:18 UTC

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


RE: facet sorting by index on sint fields

Posted by Simon Stanlake <si...@tradebytes.com>.
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:simons@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


RE: facet sorting by index on sint fields

Posted by Simon Stanlake <si...@tradebytes.com>.
Oh boy - I had a problem with my deploy scripts that was keeping an old version of the schema.xml file around. SortableIntField is working fine for me now. Sorry to waste everyone's time and thanks for the responses.

Simon
-----Original Message-----
From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of Yonik Seeley
Sent: Tuesday, August 04, 2009 2:28 PM
To: solr-user@lucene.apache.org
Subject: Re: facet sorting by index on sint fields

On Thu, Jul 30, 2009 at 10:28 PM, Simon Stanlake<si...@tradebytes.com> wrote:
> 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.

This is not the intention - seems like a bug somewhere.  Is it still
broken in trunk?  are you using distributed search?

-Yonik
http://www.lucidimagination.com

Re: facet sorting by index on sint fields

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Tue, Aug 4, 2009 at 5:27 PM, Yonik Seeley<yo...@lucidimagination.com> wrote:
>> 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.
>
> This is not the intention - seems like a bug somewhere.  Is it still
> broken in trunk?  are you using distributed search?

OK, I just tried trunk with the example docs, with the popularity
field indexed as both int (now trie based) and sint - both seem to
work correctly.

http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=popularity&facet.sort=lex

-Yonik
http://www.lucidimagination.com

Re: facet sorting by index on sint fields

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Jul 30, 2009 at 10:28 PM, Simon Stanlake<si...@tradebytes.com> wrote:
> 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.

This is not the intention - seems like a bug somewhere.  Is it still
broken in trunk?  are you using distributed search?

-Yonik
http://www.lucidimagination.com