On 10/16/06, Charlie Hubbard <[EMAIL PROTECTED]> wrote:
> David Balmain wrote:
>
> > Well the user would just type their query as usual but you'd write the
> > query something like:
> >
> > Books.find("pages match '#{query}'", :limit => 10)
> >
> > Or something like that. I haven't worked the details yet. And you
> > would be able to specify whether you wanted lazy or eager loading too.
>
> That's what I guessed you'd have to do.  Change the query language to
> support this concept.  I was actually working on adding a new method to
> acts_as_ferret where you could pass these associations matches in like:
>
> Book.find_by_association( query, [:pages], { :limit => 20 } )
>
> Since I can't change the query language, but I could express the same
> sort of behavior.  This would result in a multi_index query across Book
> and Page indexes.  But, tracking total_hits, and paging just don't work
> with this approach.  The only option you have is to iterate over all the
> matches.
>
> When we do ferret queries does ferret actually go over the entire search
> space to calculate all the possible documents that matched the query?
> Then just returns the ones within the offset and limits?

Yes, that's exactly how it works.

> If that's the case then it's doable to create this type of search, but
> it would make more sense to modify ferret to support this type of query.

I don't see a way to add this feature cleanly. It is just as easy for
you to do iterate through all the results yourself. Besides, you still
haven't explained why you can't add all Pages to each Book document?
As I said, the field length limit isn't an issue. This would be the
best way to solve this problem.

> I'm interested in your database approach. It could help simplify this
> problem.  It seems doable to add this to acts_as_ferret without needing
> a seperate project.  Not to mention it's really needed in Rails apps as
> well.
>

In my suggested database approach the search would be the equivalent
of a simple SQL join query. By adding a feature like this to
acts_as_ferret you'll need to pull all the matching page ids out of
the index and peform a much slower SQL query for all books that
include those page ids. I'm not sure it is feasible but I'll leave
that decision to the acts_as_ferret developers. The best solution is
definitely to index all the pages with the book document, even if it
means indexing each page twice.

Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to