Well, I *do* have a search for products set in place, and it works
really well. I just created a :without => { :kosher_id => 0 } and the
filter worked flawlessly.

Unfortunately, my client also needs users to be able to search for
*stores* that have those particular attributes. Am I really going to
have to use collect() until I get a sufficient amount of stores? :\

On May 12, 12:38 am, Pat Allan <[email protected]> wrote:
> Ah, in that case, I'd be searching on Products, not Stores... Sphinx has no 
> concept of key-value pairs, so it doesn't know which product names are tied 
> to which kosher ids from the perspective of a Store.
>
> --
> Pat
>
> On 12/05/2010, at 3:33 PM, Nick Kezhaya wrote:
>
>
>
>
>
> > Ahh, perhaps I should better explain what I'm trying to do...
>
> > These conditions need to be met:
>
> > 1) The stores returned MUST have products that match "chicken" -
> > easily doable.
> > 2) Tricky: the products matching "chicken" in that store *cannot* have
> > a kosher_id of 0.
>
> > On May 12, 12:29 am, Nick Kezhaya <[email protected]> wrote:
> >> Oh! I didn't know about sphinx_attributes().
>
> >> It appears that product_kosher_ids is properly returning a large array
> >> of integers of the ids; however, because some of the products in each
> >> store aren't kosher, and some are, the first int at the beginning of
> >> this array is 0, along with the rest of them.
>
> >> How do I go about determining if product_kosher_ids returns more than
> >> 0?
>
> >> On May 11, 10:04 pm, Pat Allan <[email protected]> wrote:
>
> >>> Hi Nick
>
> >>> I'm not sure what the issue is, so can you run the following in 
> >>> script/console:
>
> >>>   Store.search(:conditions => {:product_names => 'chicken'}).collect { 
> >>> |store|
> >>>     store.sphinx_attributes['product_kosher_ids']
> >>>   }
>
> >>> This will get us the details on what Sphinx is storing for that attribute.
>
> >>> --
> >>> Pat
>
> >>> On 12/05/2010, at 11:57 AM, Nick Kezhaya wrote:
>
> >>>> class Store < ActiveRecord::Base
> >>>>  has_many :product_stores
> >>>>  has_many :products, :through => :product_stores
>
> >>>>  define_index do
> >>>>    indexes :name
> >>>>    indexes [products(:name), products(:brand)], :as => :product_names
>
> >>>>    has products(:kosher_id), :as => :product_kosher_ids
> >>>>  end
> >>>> end
>
> >>>> Oddly:
>
> >>>> Store.search :conditions => { :product_names => 'chicken' }
>
> >>>> ^ This returns stores properly, but:
>
> >>>> Store.search :conditions => { :product_names => 'chicken' }, :without
> >>>> => { :product_kosher_ids => 0 }
>
> >>>> ^ Returns an empty array. I've no idea why.
>
> >>>> I know the data is present in the database.
>
> >>>> --
> >>>> 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 
> >>> 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 
> >> 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 
> > 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 
> 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