That'll be in the 'obvious' category then. I was sure I had tried
that, but on double checking I was using :condition, not :with.

My next question was going to be if I could filter by :stores having a
store in common with an array of stores, but it seems that
Song.seach :with => {:stores => store_array} works perfectly for that
case as well.

Thanks for the quick reply, glad to see Thinking Sphinx is even
cleverer than I thought!

On Sep 3, 3:18 am, Pat Allan <[email protected]> wrote:
> Hi Tom
>
> Since you've got store ids there as a multi-value attribute, this is  
> easy enough:
>
>    Song.seach :with => {:stores => special_store_id}
>
> This will return all songs that have the specific store as one of  
> their stores.
>
> You can't neatly do this with fields though, because that brings into  
> play Sphinx's query intelligence (fuzzy), and you're doing something  
> precise.
>
> Cheers
>
> --
> Pat
>
> On 02/09/2010, at 11:50 PM, Tom <[email protected]> wrote:
>
>
>
> > If I have a model:
> > class Song < ActiveRecord::Base
> >  has_and_belongs_to_many :stores
>
> >  define_index do
> >    indexes :name
>
> >    has stores(:id), :as => :stores
> >  end
> > end
>
> > Then I can construct a search with a SQL IN() like condition using
> > something like :with => { :name => ['x','y','z] }
>
> > Is there any way of making a condition that would use IN the other way
> > round ie returning songs that have somestore as one of their stores?
>
> > Very new to Sphinx, so apologies if this is a) very obvious, or b)
> > obviously impossible.
>
> > Thanks.
>
> > --
> > 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 
> > athttp://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