Hi Josh

I'm not quite sure what you're after... do you want to search by a specific 
book on users attached to that book? ie:
  book.users.search 'foo'

This is doable - you'll need the book id as an attribute in the User model, 
though. I think this will do the job:

  has join_class.books(:id), :as => :book_ids


Or, do you want to search for users using search terms from the books they're 
attached to?

  user.books << Book.create :name => 'foo bar'
  user.books << Book.create :name => 'foo baz'
  user.save
  
  User.search 'foo' # should return user

This is easy enough, because - like in the attribute example above - you can 
pull in data from associations:

  indexes books.name, :as => :book_names


Or are you after something different to either of those situations?

-- 
Pat

On 27/03/2010, at 1:23 PM, Josh wrote:

> I am trying to figure out the best way to achieve the following and
> would appreciate any input:
> 
> class foo
>  has_many bars, :though => :join_class
> end
> 
> class bar
>  has_many :foos, :through => :join_class
> 
>  define_index do
>    indexes :name
>    indexes :description
>  end
> end
> 
> I want to search through bars and show in the results the foo's that
> have them.  For example a user has many books, I would like to search
> through books and return the users that have them.
> 
> What is the best index configuration to achieve this? Because I want
> to get foo's it seems I should build an index on that, but I am not
> sure what to index.
> 
> Thanks,
> -=Josh
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to