Sorting by score

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

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

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.

On 5/6/06, Pedro Côrte-Real [email protected] 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