On Thu, Jul 20, 2006 at 09:13:30AM +0900, David Balmain wrote:
> On 7/20/06, Caspar <[EMAIL PROTECTED]> wrote:
[..]
> > 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?
> 
> One of the acts_as_ferret guys will be able to confirm this but I
> don't think acts_as_ferret automatically converts dates to a format
> that is searchable. What you need to do is convert the DateTime to a
> format that is lexicographically sortable;
> 
>     acts_as_ferret :fields=> 
> ['short_description',...,'ferret_date_registered']
> 
>     def ferret_date_registered
>         date_registered.strftime("%Y%m%d")
>     end

that's right, you'll have to do the datetime to string conversion
yourself. I think we could add conversions like that to acts_as_ferret 
in a future version.

> This should fix your problem. Note that you if you need a little more 
> precision
> you can add hours, minutes, etc.
> 
> >               results2 = VoObject.find_by_contents(query,:num_docs=> 
> > 2000000,:sort
> =>sort_fields )
> 
> Just a word of warning. Whatever you specify num_docs to be, an array
> is created to hold that many hits, so even if your query only returns
> 2 hits, the above line will use 2 Mb (bit it will be freed immediately
> once the search is finished, not garbage collected). I might try and
> change that behaviour this morning.
> 
> On this topic, :first_doc is going to be changing to :offset and
> :num_docs to :limit. I'm toying with the idea of making :all a valid
> option for :limit to get all search results although :limit => :all
> sounds a bit funny to me. Perhaps simply :limit => nil would be
> better. Feedback anyone?

actually acts_as_ferret already supports :num_docs => :all, where the
:all gets transformed to a user-definable (via the :max_results option in
the call to acts_as_ferret) large number of records.

I agree that :limit => nil makes more sense.

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

Reply via email to