我是思考sphinx的新手我没有找到任何解决方案来帮助我使用思考sphinx索引左连接。
这是我想在sphinx中索引的查询
Company.joins("left join award_judges on award_judges.company_id = companies.id").where("companies.company_type = 'investor' AND (award_judges.award_id = 6 OR award_judges.award_id IS NULL)").select("companies.id,companies.name, award_judges.judge_application_type,award_judges.judgement_status").order("award_judges.judge_application_type, award_judges.judgement_status")
我的公司模型中的关联是
has_many :award_judges
答案 0 :(得分:1)
您可以在索引中引用索引中的关联,并且还有WHERE
条件:
indexes award_judges.judgement_status, :as => :judgement_statuses
where "companies.company_type = 'investor' AND (award_judges.award_id = 6 OR award_judges.award_id IS NULL)"