Hi Dave,

I currently only use a small subset of the Ferret API so this may not
work universally for all areas you support sorting.  One simple
sorting solution would be to just support SQL style string expressions
for sorting.  It should be relatively easy to implement.  So this
code:

    sort_fields = []
    sort_fields << Ferret::Search::SortField.new('created_at')
    sort_fields << Ferret::Search::SortField.new('url')
    num = INDEX.search_each(query, :sort => sort_fields)  do |doc, score|

Could be rewritten as:
    num = INDEX.search_each(query, :sort => 'created_at, url') do |doc, score|

And perhaps it could also support ASC DESC syntax as well.

In general I think anywhere the Ferret API requires us to create
internal Ferret classes and pass them in it would be nice if there was
a way to abstract this from the caller as much as possible using
simple datastructures such as symbols, strings and arrays.

Tom

On 6/30/06, David Balmain <[EMAIL PROTECTED]> wrote:
> On 6/30/06, Jens Kraemer <[EMAIL PROTECTED]> wrote:
> > On Thu, Jun 29, 2006 at 06:19:48PM +0100, Pedro CĂ´rte-Real wrote:
> > [..]
> > > > this will be fixed in the soon-to-be-released next version.
> > >
> > > Cool. I hate having non-standard patches to stuff. It would also be cool
> > > to have a cleaner API to do sorting than the ferret one. One that uses
> > > the field names passed to acts_as_ferret. Ferret is great but it's API
> > > seems to be too much like Java and not like most ruby API's. I ended up
> > > building a small class to encapsulate searching for my rails model to
> > > hide all that away.
> >
> > Good point, but I'd rather wait for ferret's upcoming API changes before
> > doing such changes in acts_as_ferret.
> >
> > Jens
>
> That's a very good plan. While we are on the subject, how do you think
> the sort API should look? Once we get to a 1.0 release we are going to
> be stuck with that API for a while so I want to get it right before
> then and the sooner the better. Also, what other areas of the API do
> you feel need work. For starters, I'll be getting rid of the Parameter
> class. Instead of Field::Index::TOKENIZED it'll just be :index => :yes
> or :index => :untokenized etc. Anyway, I'd love to hear any feed back
> on any part of the API. Let's start with the Sort API.
>
> Cheers,
> Dave
> _______________________________________________
> Ferret-talk mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/ferret-talk
>


-- 
Tom Davies

http://atomgiant.com
http://gifthat.com
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to