Eager loading associations when using a More Like This Query
Reported by Lukas Rieder | March 24th, 2011 @ 10:37 AM
Hy,
recently we encountered an issue where data_accessor_for(...) is only implemented in Sunspot::DSL::Search. So this method, which we would like to use for eager loading associations, is not available in a Sunspot::DSL::MoreLikeThisQuery.
Could you make it available so that we can use code like the following?
Sunspot.more_like_this(self, Document) do
fields :title, :plain_text
data_accessor_for(Document).include = [:authors, :editors]
end
At the moment I've just monkeypatched it into my application, but my knowledge of sunspot's internals is very weak. So if you point me the way, I'd be happy to submit a patch.
Cheers, Lukas
Comments and changes to this ticket
-

Lukas Rieder March 24th, 2011 @ 10:37 AM
- → Title changed from Eager loading associations when using a More Like Query to Eager loading associations when using a More Like This Query
-

Lukas Rieder March 24th, 2011 @ 10:38 AM
Here is the monkeypatch:
Sunspot::DSL::MoreLikeThisQuery.class_eval do def data_accessor_for(clazz) @search.data_accessor_for(clazz) end end -

mat January 28th, 2012 @ 01:16 PM
- → State changed from new to resolved
(from [48c40a93498f613845b2eb161157032adca76986]) [Closes #173] Changelog for fixing deprecation warning https://github.com/sunspot/sunspot/commit/48c40a93498f613845b2eb161...
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