I realized that I wasn't fully clear in this example...I would want
returned all Book objects where the Book description contains the word
'programming', the Author name contains the word 'Smith', AND (what I
didn't explicitly say before) the book is by that author. So more
informally, I want to find all programming books who are by someone with
'Smith' in their name. This would amount to the extra join statment of
'books.author_id=author.id'. I'm having a really hard time figure out
how to do this in Ferret (using acts_as_ferret).
Jon wrote:
> I'm having trouble figuring out how to do Ferret queries across multiple
> tables as you would in a normal SQL call. For example, let's say I have
> two ActiveRecord classes, Book, and Author, where Book has a
> 'description' field and Author has a 'name' field, and where Book has a
> belongs_to relationship with Author (Book belolngs to Author, Author
> has_many Books). Let's say I'd like to find all Books with the term
> 'programming' in their description that are by people with 'Smith' in
> their name. I'd like to do something like this:
>
> Book.find_by_contents("books.description:programming AND
> authors.name:Smith",
> {},
> {:include => :author})
>
> However, this function does not seem to allow the specification of table
> names. This type of call would be relatively easy in plain SQL, but I'd
> like to use Ferret for all queries to keep things uniform and to take
> advantage of its speed. I've looked into using the multi_search option
> also, but can't figure out how to use it to do even simple joins such as
> this one. Any help would be greatly appreciated. Thanks.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk