In my model Topic:

acts_as_ferret({ :fields => {:username => {:store => :yes, :boost =>
30}, :subject => {:store => :yes, :boost => 20}, :body => {:store =>
:yes, :boost => 10}}, :remote => true }, { :analyzer =>
Ferret::Analysis::RegExpAnalyzer.new(/./, false) })

def self.full_text_search(q, options = {}, find_options = {})
   return nil if q.nil? or q==""
   default_options = {:limit => 10, :page => 1}
   options = default_options.merge options

   # get the offset based on what page we're on
   options[:offset] = options[:limit] * (options.delete(:page).to_i-1)

   # now do the query with our options
   results = Topic.find_by_contents(q, options, find_options)
   return [results.total_hits, results]
end

in my SearchController:

if params[:doSearch] == "true"
if params[:query] == ""
flash[:notice] = 'Please enter some words to search on.'
else
@conditions = " 1 = 1";
if params[:dateRange] != ""
@conditions += " and creationDate >= " + params[:dateRange]
end
if params[:forumID] != ""
@conditions += " and forum_id = " + params[:forumID]
end

@total, @topics = Topic.full_text_search(params[:query], {:page =>
(params[:page]||1)}, {:conditions => @conditions})
@pages = pages_for(@total)
end

it always return only 10 search results. no more search result. i don't
know why!

and this article doesn't work!
http://www.ruby-forum.com/topic/93822

thanks!

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to