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 Gal Nitzan <ga...@gmail.com> on 2007/05/08 11:15:57 UTC

sorting problem

Hi,

I have 2 fields which I would like to sort by, one is a "date" field and the 
other is "sint".

My query tries to search all entries which their ctype is video sorted by 
tstamp descending and then sorted by popularity:

q=ctype:video;tstamp desc;popularity desc&fl=tstamp,popularity

However the results returned are sorted only by the tstamp.

<doc>
<int name="popularity">0</int>
<date name="tstamp">2007-05-08T12:58:45,023Z</date>
</doc>
<doc>
<int name="popularity">0</int>
<date name="tstamp">2007-05-08T12:58:39,062Z</date>
</doc>
<doc>
<int name="popularity">4923</int>
<date name="tstamp">2007-05-08T12:58:37,710Z</date>
</doc>
<doc>
<int name="popularity">0</int>
<date name="tstamp">2007-05-08T12:58:37,651Z</date>
</doc>

Any idea what I'm missing?

TIA,

Gal




RE: sorting problem

Posted by Gal Nitzan <ga...@gmail.com>.
Thank you, Hoss...

> -----Original Message-----
> From: Chris Hostetter [mailto:hossman_lucene@fucit.org]
> Sent: Tuesday, May 08, 2007 8:41 PM
> To: solr-user@lucene.apache.org; gal.nitzan.1@gmail.com
> Subject: Re: sorting problem
>
>
> : My query tries to search all entries which their ctype is video sorted
> by
> : tstamp descending and then sorted by popularity:
>
> : However the results returned are sorted only by the tstamp.
>
>
> Solr stores datefields with millisecond precision, so if you index a date
> field without rounding, then all of htat precision is going to be there
> when it comes time to sort ... you can clearly see in your output that the
> results are strictly sorted by your first critera .. the secondary sort
> will only come into play if two docs have *exactly* the same value for the
> tstamp field.
>
> assuming you generate your tstamp field using the "NOW" default in your
> schema.xml, you can get rounding by using the DateMath feature, something
> like this...
>
>    <field name="timestamp" type="date" default="NOW/MINUTE" />
>
> ...but if you are generating the tstamp field values in your client and
> then sending them to Solr, you'll need to do the rounding there.
>
> -Hoss



Re: sorting problem

Posted by Chris Hostetter <ho...@fucit.org>.
: My query tries to search all entries which their ctype is video sorted by
: tstamp descending and then sorted by popularity:

: However the results returned are sorted only by the tstamp.


Solr stores datefields with millisecond precision, so if you index a date
field without rounding, then all of htat precision is going to be there
when it comes time to sort ... you can clearly see in your output that the
results are strictly sorted by your first critera .. the secondary sort
will only come into play if two docs have *exactly* the same value for the
tstamp field.

assuming you generate your tstamp field using the "NOW" default in your
schema.xml, you can get rounding by using the DateMath feature, something
like this...

   <field name="timestamp" type="date" default="NOW/MINUTE" />

...but if you are generating the tstamp field values in your client and
then sending them to Solr, you'll need to do the rounding there.

-Hoss