[Ferret-talk] Sorting issues, can anyone help me?

Jens Kraemer
2007-04-01T09:10:27Z

On Sat, Mar 31, 2007 at 03:45:40PM +0200, Manoel Lemos
wrote:
> I have this model:
>
> class Post < ActiveRecord::Base
>
>   acts_as_ferret  :fields => {  :title            => {:boost =>
2},
>                                 :description      => {},
>                                 :url              => {},
>                                 :rank_sort        => {:index =>
> :untokenized_omit_norms, :term_vector => :no},
>                                 :posted_at_sort   => {:index =>
> :untokenized_omit_norms, :term_vector => :no}
>                             },  :remote => true
>
>   belongs_to :blog
>
[..]
> >> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :no)}
)[1].last.posted_at_sort
> => [1085549830]

First of all, use symbols for your field name (don''t know if that
solves the problem, but you should use symbols for fieldnames
everywhere).

Then, try to give an array of sort fieldsas value of the :sort
parameter, and specify the correct type for your integer fields. So to
sort by rank_sort, descending, do:

:sort => [ Ferret::Search::SortField.new(:rank_sort, :type => :integer,
:reverse => true) ]

Jens

--
Jens Kr?mer
webit! Gesellschaft f?r neue Medien mbH
Schnorrstra?e 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
kraemer at webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa