Hi Tyler

What does the source for the product model look like in your 
config/development.sphinx.conf file? (Make sure you remove your database 
password).

Cheers

-- 
Pat

On 15/10/2010, at 4:42 AM, Tyler Smith wrote:

> In my Product.rb
> 
> define_index do
>    indexes :name, :sortable => true
>    indexes brand
> 
>    has :id, kosher_id, gluten_free_id, lactose_free_id
>    has stores(:id),        :as => 'store_ids'
>    has locations(:id),     :as => 'location_ids'
>    has categories(:id),    :as => 'category_ids'
>    has kosher(:passover),  :as => 'kosher_passover'
>  end
> 
> In my Searching Class
> 
> def self.for_locations_by_query(query, options = {})
>    query, categories = @@coder.decode(query).gsub(/(\b\w+\b)/, "+\
> \0"), @@coder.decode(options.delete(:categories))
>    origin, page = @@coder.decode(options.delete(:origin)),
> @@coder.decode(options.delete(:page))
>    per_page, sort_order = @@coder.decode(options.delete(:per_page)),
> @@coder.decode(options.delete(:sort_order))
>    distance, classifications =
> @@coder.decode(options.delete(:distance)),
> @@coder.decode(options.delete(:classifications))
> 
>    with                        = {}
>    with[:store_ids]            = Location.all(:origin =>
> origin, :within => distance).collect(&:store_id).uniq unless
> origin.blank? or distance.blank?
>    with[:category_ids]         = categories.split(',') unless
> categories.blank?
> 
>    without                     = {}
>    without[:kosher_id]         = 0 if
> classifications.split(',').include? 'kosher'
>    without[:gluten_free_id]    = 0 if
> classifications.split(',').include? 'gluten_free'
>    without[:lactose_free_id]   = 0 if
> classifications.split(',').include? 'lactose_free'
>    without[:kosher_passover]   = 0 if
> classifications.split(',').include? 'kosher_passover'
> 
>    products  = Product.search(query, :with => with, :without =>
> without, :per_page => 20, :page => 1)
>    stores    = products.collect { |p| p.stores }.flatten.uniq
>    locations = stores.collect { |s| s.locations.find(:all, :origin =>
> origin, :within => distance) }.flatten.uniq
>    locations.sort_by_distance_from(origin)
>    locations.each { |l| l.dist = l.distance }
> 
>    locations = locations.paginate(:page => page, :per_page =>
> per_page)
> 
>    return { :total_entries => locations.total_entries, :size =>
> locations.size, :locations => locations }
>  end
> 
> The problematic line is with[:store_ids] = ...
> The product can be associated to multiple store ids, however it only
> seems to work if the lowest numbered ID is in the array for
> with[:store_ids].  For example, the ids associated with product 1000
> are [12,15,41], if with[:store_ids] = [15,41] then 0 results are
> returned, however if 12 is in the array then it works.
> 
> I have stopped, started, restarted, reindexed, rebuilt, generated a
> new conf file for sphinx, and repeated in various orders and I have
> had no luck.
> 
> -- 
> 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