The solution, just like MaurÃcio Linhares wrote in his comment, is to go through the actors model and group by movies The problem is that Sunspot doesn't support Solr 3.3 or 4.0, which is the only Solr versions that support grouping Here is my solution using Sunspot 1.2.1 and Solr 3.3 In my example movie_id is placed in the actors table, this isn't done in my real application Schema Information # # Table name: actors # # id :integer(4) not null, primary key # name :string(255) # created_at :datetime # updated_at :datetime # movie_id :integer(4) # class Actor New_search(Actor) scoped. Build do adjust_solr_params do |params| params:group = true params:"group. Field" = "movie_id_s" params:"group.
Format" = "simple" end end # Sunspot 1.2.1 doesn't support grouping, so we need to do some hacking. Def scoped. Ts @hits ||= @solr_result"grouped".values.
First"doclist""docs". Map do |doc| Sunspot::Search:: New(doc, nil, self) end end def scoped. Total @total ||= @solr_result"grouped""movie_id_s""matches" || 0 end # Here we'll only fetch the stored data from Solr it self, # and then pass it manualy to ActiveRecord.Movie.
Where({ id: scoped.execute.hits. Map{ |h| h. Stored(:movie_id) } }) end end Cred to alindeman for his example gist.
The solution, just like MaurÃcio Linhares wrote in his comment, is to go through the actors model and group by movies. The problem is that Sunspot doesn't support Solr 3.3 or 4.0, which is the only Solr versions that support grouping. Here is my solution using Sunspot 1.2.1 and Solr 3.3.In my example movie_id is placed in the actors table, this isn't done in my real application.
# == Schema Information # # Table name: actors # # id :integer(4) not null, primary key # name :string(255) # created_at :datetime # updated_at :datetime # movie_id :integer(4) # class Actor To_s end end def search_using_solr scoped = Sunspot. New_search(Actor) scoped. Build do adjust_solr_params do |params| params:group = true params:"group.
Field" = "movie_id_s" params:"group. Format" = "simple" end end # Sunspot 1.2.1 doesn't support grouping, so we need to do some hacking. Def scoped.
Ts @hits ||= @solr_result"grouped".values. First"doclist""docs". Map do |doc| Sunspot::Search::New(doc, nil, self) end end def scoped.
Total @total ||= @solr_result"grouped""movie_id_s""matches" || 0 end # Here we'll only fetch the stored data from Solr it self, # and then pass it manualy to ActiveRecord. Movie. Where({ id: scoped.execute.hits.
Map{ |h| h. Stored(:movie_id) } }) end end Cred to alindeman for his example gist.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.