On 10/15/06, Charlie Hubbard <[EMAIL PROTECTED]> wrote:
> David Balmain wrote:
>
> > If I manage to implement the Ferret object database[1] this will be
> > simple. Currently though there are two ways to do this. You can index
> > all of the Page data in the Book document, presumably in a :page
> > field. Or you can store the Book ids in the Pages and create a Book id
> > set by scanning through all matching pages.
> >
> > [1] http://www.ruby-forum.com/topic/82086#142613
>
> The first option has problems because a book's content will be too large
> for a single field.  It would overrun ferret's maximum field length.

Then change the maximum field length. IndexWriter has a
:max_field_length parameter.

> I'm pretty much doing the second option now.  But, it's drawback is
> pagination gets tough.  I'm not sure how having the ferret object
> database would actually work to solve this problem.  How would your
> queries express what the user intends?  How would it know I want to
> include all the Page objects as apart of a search on Books?  Seems like
> you'd have to specify that sort of thing as options to the search.  Like
> we have to specify eager loading with :include option to find.

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.

> >> Is there something in ferret that allows me to scroll through the
> >> results one by one and stop when I've reached my limit?
> >
> > Sure. Set :limit => :all and call search_each. Then break when you
> > reach your limit.
>
> That will work for creating a list of Books, and ensuring a show say 10
> unique books per page.  But, I won't be able to tell what the total
> number of hits were.  Any ideas?
>
> Also it gets hard to do pagination because you can't compute where the
> next window starts and ends.  So how do you know what the offset
> parameter is for the previous pages.  Or the offset for the 9th page is?
>

Scroll through all matches or use option 1.

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

Reply via email to