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

Manoel Lemos
2007-03-31T13:45:40Z

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

  def rank_sort
    begin
      return self.blog.rank_links.to_i
    rescue
      return nil
    end
  end

  def posted_at_sort
    begin
      return self.posted_at.to_i
    rescue
      return nil
    end
  end

end

But when I try to sort by :rank_sort or :posted_at_sort it didn''t work,
see:

>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => false)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => false)}
)[1].last.posted_at_sort
=> [1085549830]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => true)}
)[1].last.posted_at_sort
=> [1085549830]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => true)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => :true)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new(:rank_sort, :reverse => :false)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :false)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => false)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => true)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :true)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :yes)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :no)}
)[1].first.posted_at_sort
=> [1146857920]
>> h,r = Post.full_text_search("voltamos", {:sort =>
Ferret::Search::SortField.new("rank_sort", :reverse => :no)}
)[1].last.posted_at_sort
=> [1085549830]
>>

Can anyone help me with this?

[]s

Manoel

--
Posted via http://www.ruby-forum.com/.