[Rails] Eager Loading When Searching
I think it would be great to be able to eager load association
when doing a search.
Something similar to
Post.search(:include => :author) do keywords "keyword" end
so it would eager load the authors of the resulting posts
Comments and changes to this ticket
I figured out I can do the following
Post.search do data_accessor_for(Post).include = [:author] keywords "keyword" end
I have 2 comments however
1. I was unable to obtain this info through documentation, I had to go through the code to figure out
2. it's not the best syntax for the purpose
The existing API is provided by pure Sunspot, which has no knowledge of either ActiveRecord or what an
:includemight mean. It also accounts for the possibility that you are searching for more than one object type, in which case you might want to give different options to different data accessors.
However, I like your idea for Sunspot::Rails -- it is much friendlier.
- State changed from new to resolved
(from [402fe53c847d92426d397bcb7c351c435c990c44]) Allow specify of eager loading in Searchable::search()
(from [2de17fa003dacff20ddb6ef87e11b5d7edb1dc4b]) Expose :select option in #search method