[Rails] Eager Loading When Searching
Reported by humanzz | March 11th, 2010 @ 06:21 AM | in Feature Requests
Hello,
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
-

humanzz March 11th, 2010 @ 07:01 AM
I figured out I can do the following
Post.search do data_accessor_for(Post).include = [:author] keywords "keyword" endI 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 purposeThanks
-

mat March 11th, 2010 @ 10:35 AM
- Milestone set to Feature Requests
-

mat March 11th, 2010 @ 10:37 AM
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.
-

mat March 11th, 2010 @ 10:50 AM
- State changed from new to resolved
(from [402fe53c847d92426d397bcb7c351c435c990c44]) Allow specify of eager loading in Searchable::search()
[#90 state:resolved] http://github.com/outoftime/sunspot/commit/402fe53c847d92426d397bcb...
-

humanzz March 11th, 2010 @ 11:06 AM
Thanks for that fast commit, mat :)
I saw that support for both keys :include and :select is included in ActiveRecordDataAccessor. So I believe it makes sense to add support for :select in addition to :include -

mat March 11th, 2010 @ 11:24 AM
(from [2de17fa003dacff20ddb6ef87e11b5d7edb1dc4b]) Expose :select option in #search method
[#90] http://github.com/outoftime/sunspot/commit/2de17fa003dacff20ddb6ef8...
-

-

mat December 27th, 2010 @ 02:28 PM
- Tag changed from eager loading, feature-request, rails to eager loading, feature, rails
- Milestone order changed from 0 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Awesome Solr interaction for Ruby
Tags
Referenced by
-
#90 [Rails] Eager Loading When Searching
[#90
state:resolved]
http://github.com/outoftime/sunspot...
-
#90 [Rails] Eager Loading When Searching
[#90]
http://github.com/outoftime/sunspot/commit/2de17fa...