Skip to content

Instantly share code, notes, and snippets.

@bencrouse
Created August 18, 2011 21:36
Show Gist options
  • Save bencrouse/1155301 to your computer and use it in GitHub Desktop.
Save bencrouse/1155301 to your computer and use it in GitHub Desktop.
Sunspot.session = CoreShardingSessionProxy.new(Sunspot.config)
# Causes error
# /Users/bcrouse/.rvm/gems/ruby-1.9.2-p0@solr_plexus/gems/sunspot-1.2.1/lib/sunspot/session_proxy/abstract_session_proxy.rb:21:in `config': Sunspot::SessionProxy::ShardingSessionProxy does not support :config (Sunspot::SessionProxy::NotSupportedError)
class CoreShardingSessionProxy < Sunspot::SessionProxy::ClassShardingSessionProxy
def initialize(*)
super
@core_sessions = Site.all.inject({}) do |sessions, site|
session = Sunspot::Session.new
session.config.solr.url = "http://localhost:8983/solr/#{site.core_name}"
sessions[site.id] = session
sessions
end
end
def session_for_class(klass)
@core_sessions[klass.site_id] # Simplified to get the idea
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment