Solr Search with one to many associations

I have a 2 entities which have one to many relation say teacher and
slot. Each teacher has many classes he/she takes up and each class is a
slot. I want to perform search on teacher by sunspot solr for all the
teacher who takes classes for different days in specific time.

Say model structures and relations as follows

class Teacher < ActiveRecord::Base

  attr_accessible - name, address, phone
  has many :slots

  searchable do

    string :day, multiple => true, stored => true do

    string :start_time, multiple => true, stored => true do

    string :start_time, multiple => true, stored => true do

class Slot < ActiveRecord::Base
  attr_accessible - day, start_time, end_time teacher_id
  belongs_to :teacher

The possible values for day attribute is slot are “Sunday”, “Monday”,
“Tuesday”, etc
and start and end time would be “2:00pm”, “6:00pm”, etc in the database

How would I perform solr search query for the teachers who are having
for 3 days Monday, Tuesday and Wednesday between the time “2:00pm” and

I am trying with following code which is not taking “AND” condition to
retrieve only the teachers having classes all 3 days rather taking as
“OR” condition. do
  with(:day, "Monday")
  with(:day, "Tuesday")
  with(:day, "Wednesday")

I am using solr version 3.5 and sunspot_rails (2.0.0) and sunspot_solr
(2.0.0) gems for solr in rails and my rails version is 3.2.6

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs