Here is the sql that I have: SELECT `uploads`.`id` * 3 + 1 AS `id` , CAST(`uploads`.`description` AS CHAR) AS `description`, UNIX_TIMESTAMP(`uploads`.`created_at`) AS `created_at`, `uploads`.`creator_id` AS `creator_id`, GROUP_CONCAT (`subscriptions`.`user_id` SEPARATOR ',') AS `user_id`, `uploads`.`id` AS `sphinx_internal_id`, 269607721 AS `class_crc`, '269607721' AS `subclass_crcs`, 0 AS `sphinx_deleted`
FROM uploads LEFT OUTER JOIN `entities` ON `entities`.id = `uploads`.entity_id LEFT OUTER JOIN `subscriptions` ON subscriptions.entity_id = entities.id WHERE `uploads`.`id` >= $start AND `uploads`.`id` <= $end AND `uploads`.`delta` = 0 GROUP BY `uploads`.`id` ORDER BY NULL On Feb 10, 11:45 pm, Pat Allan <[email protected]> wrote: > Hi Brian > > From an initial look, it seems like you're doing the right thing - > although entity.subscriptions(:user_id) could be done as > entity.subscriptions.user_id. > > What's the sql_query in your development.sphinx.conf file for the > Upload index? > > -- > Pat > > On 11/02/2009, at 5:27 AM, brian wrote: > > > > > I'm trying to get associations working, but can't seem to get it > > right. I have users, who can subscribe to entities. Entities have > > uploads and uploads have descriptions. I want to search > > upload.description through all of a user's subscription. > > > Here are my models: > > > class User < ActiveRecord::Base > > has_many :subscriptions > > has_many :entity_subscriptions, :through => :subscriptions, :source > > => 'entity' > > has_many :entities, :foreign_key => 'owner_id' > > ... > > end > > > class Entity < ActiveRecord::Base > > has_many :uploads > > has_many :subscriptions > > has_many :subscribers, :through => :subscriptions, :source => 'user' > > ... > > end > > > class Subscription < ActiveRecord::Base > > belongs_to :entity > > belongs_to :user > > end > > > class Upload < ActiveRecord::Base > > belongs_to :entity > > > define_index do > > indexes description > > has :created_at > > has :creator_id > > has entity.subscriptions(:user_id), :as => :user_id > > set_property :delta => true > > end > > ... > > end > > > If I add in user id, i don't get subscriptions for the user that I > > want. I think I've just set it up wrong, any help is greatly > > apprieciated. > > > Thanks, > > Brian > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
