On Mon, Oct 02, 2006 at 09:15:43AM +0200, David Wennergren wrote:
> > For some queries, the sorting is correct. Other times, it's not. I'm not
> > sure what's causing this. Any help would be greatly appreciated!
>
> I've had the same problem. I solved it by using the find_options in
> find_by_contents method. Like this:
>
> find_by_contens(q, options, find_options)
>
> find_options is a hash passed on to active_record’s find when retrieving
> the data from db, useful to i.e. prefetch relationships.
>
> So for your query:
>
> @results = Listing.find_by_contents @search_criteria, {:limit => :all,
> :sort => sort_fields},{:order => "name ASC"}
>
> I'm not sure this is the best way but it worked for me.
please note that this will only work with :limit => :all, otherwise
you'll only sort the subset of records retrieved from ferret, not the
whole result set.
As :limit => :all can be *very* expensive (with Ferret returning
all results, and aaf fetching them all from the db), making the Ferret
sorting work correctly would be the better way.
Is the correctness of sorting related to a special kind of queries ?
Jens
--
webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [EMAIL PROTECTED]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk