I’m trying to add a way to query across associations for a model in
acts_as_ferret. Say I have a model A and it has a relationship with
model B. Like say a Book has many pages. I want to search across the
pages of the Book and produce a list of unique books who’s pages match
the terms. So if I have a page that hits then I will add that book to
my list of results. Right now the multi_search returns all pages and
books that match the query.
This sort of gets difficult with pagination because you can’t just keep
track of it yourself. Also the total hits will include all hits on
pages and books. The way the pagination works today with ferret is you
hand it :offsets and :limit params. But, these are fixed width params.
I could end up with 100’s of pages that all belong to the same book so I
have to skip all of those.
This sort of seems like a different kind of search. Not a multi_search
or find_by_contents, but a find_by_association. Where the hit on the
association returns an object of the associated type.
Is there something in ferret that allows me to scroll through the
results one by one and stop when I’ve reached my limit?