Forum: Ferret Sorting by score

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Pedro =?ISO-8859-1?Q?C=F4rte-Real?= (Guest)
on 2006-05-05 15:16
(Received via mailing list)
I'm trying to sort by score but it seems like SortField::SortType::SCORE
is 0 instead of a SortType. A test case is attached. Without the C
extensions the test passes, so I guess it's a bug in them. Should I be
using it without the extensions? Because if that's the case I have some
other bugs to report.

Greetings,

Pedro Côrte-Real
David B. (Guest)
on 2006-05-05 18:51
(Received via mailing list)
Hi Pedro,

This isn't a bug in either. Ferret with the extensions differs
slightly from Ferret without the extensions. This is unfortunate but
it's something you'll have to live with for a while yet. I have a lot
of other things to work on before I get back to working on the pure
Ruby version of Ferret. Sorry about this.

Dave
Pedro =?ISO-8859-1?Q?C=F4rte-Real?= (Guest)
on 2006-05-05 19:03
(Received via mailing list)
On Fri, 2006-05-05 at 23:49 +0900, David B. wrote:
> Hi Pedro,
>
> This isn't a bug in either. Ferret with the extensions differs
> slightly from Ferret without the extensions. This is unfortunate but
> it's something you'll have to live with for a while yet. I have a lot
> of other things to work on before I get back to working on the pure
> Ruby version of Ferret. Sorry about this.

No problem, but then how do I sort by score with the extensions?

Pedro.
David B. (Guest)
on 2006-05-05 19:28
(Received via mailing list)
On 5/6/06, Pedro Côrte-Real <removed_email_address@domain.invalid> wrote:
>
> Pedro.

Oh, now I see what you are asking. Just the same way as you would
without the extensions. This much is the same in both versions. The
fact that the SortTypes are integers instead of SortType objects is
just an implementation issue. Actually you should use
SortField::FIELD_SCORE. So if you wanted to sort by create_date
(stored like "20060505") and then by score you could create a sort
like this;

    date_sf = SortField.new(:create_date, {:sort_type =>
SortField::SortType::INTEGER})

    sort = Sort.new([date_sf, SortField::FIELD_SCORE])

In fact, it will work out that the field is an integer field itself so
you could just do this;

    sort = Sort.new(["create_date", SortField::FIELD_SCORE])

Hope that helps,
Dave
This topic is locked and can not be replied to.