sunspot solr search on multiple fields of associated models

I have a 2 entities which have many to many relation say teacher and subject. Each teacher has many subjects. I want to perform search on teacher by sunspot solr for all the teacher who teaches 3 subjects biology, anatomy and botany with specific time.


Just go through the below link.