Hello All,
Okay i think I'm finally getting all of what i want out of ferret
working, thanks mostly to reading this forum and also getting ALOT of
questions answered, thanks alot everyone. Anyway my last ferret task is
too get the results sorted by a field called date_registered and have
this working with pagination.
here is what i'm doing at the moment:
################################
acts_as_ferret :fields=> ['short_description',...,'date_registered']
def VoObject.find_results(query,page)
sort_fields = []
sort_fields << Ferret::Search::SortField.new("date_registered",
:reverse => :false)
results2 = VoObject.find_by_contents(query,:num_docs=>
2000000,:sort
=>sort_fields )
num = results2.size
if page == 1
page = 0
else
page = (page-1)*20
end
results = VoObject.find_by_contents(query,:first_doc=>page,
:num_docs=> 20,:sort => sort_fields)
[num,results,results2]
end
##############################
I added date_registered to the ferret fields and rebuilt the index (not
sure if this is neccessary but anyway) but my results page still shows
the results in a random order. Seems like the sorting has no effect.
date_registered is a date_time field. I call ifnd by contents twice in
the above code because i need to populate some dropdowns with values for
the entire returned results so that they can be used to refine the
search. Also just from the look of this code am i right in thinking that
each page of results will be sorted but not the entire returned results?
Any ideas?
thanks
regards
Caspar
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk