Hi,

I have models set up as follows:

class Promotion < ActiveRecord::Base

  # associations
  has_many :campaigns, :dependent => :destroy
  has_many :sites, :through => :campaigns

  define_index do
    indexes :title
    indexes :details

    indexes sites.lat, :as => :site_lat
    indexes sites.lng, :as => :site_lng
    has 'RADIANS(sites.lat)', :as => :lat, :type => :float
    has 'RADIANS(sites.lng)', :as => :lng, :type => :float
    set_property :latitude_attr   => "lat"
    set_property :longitude_attr  => "lng"
    has status, starts_at, expires_at
  end
end

class Campaign < ActiveRecord::Base
  belongs_to :promotion
  belongs_to :site
end

class Site < ActiveRecord::Base
  acts_as_mappable

  # associations
  has_many :campaigns, :dependent => :destroy
  has_many :promotions, :through => :campaigns
end

When I call Promotion.search I only get results for the promotions
that have a single record in Campaigns. So, If I have a Promotion that
is associated with more than 1 Site, I don't get any results back for
that Promotion. For example, I might have a Promotion with a title of
'widgets' that is available in Birmingham and London. If I search with
the keyword 'widget' and location 'London', I would expect my search
to return the promotion, but, it doesn't. If I delete from the
Campaigns table the row that associates the promotion to the site in
Birmingham, and search again, the promotion gets returned
successfully.

Can anyone advise why this is, and what I need to change about my
search to be able to return Promotions that are associated with more
than one site?

Thanks for all your help
Alex

-- 
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