-
Notifications
You must be signed in to change notification settings - Fork 253
Solr Configuration
Chris Beer edited this page Feb 1, 2014
·
8 revisions
The Solr connection parameters are configured globally in config/solr.yml. Out of the box, it looks something like this:
# config/solr.yml
development:
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr" %>
test: &test
url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr" %>Blacklight parses the YAML file using ERB, which means you can use environment variables (as above), class methods, etc.
The configuration is used to configure RSolr::Client. Available options include:
- url
- proxy
- open_timeout
- read_timeout
- retry_503
- retry_after_limit
The solr.yml file works for static, global Solr connections. Some use cases require dynamic configuration (based on the request or otherwise). Blacklight provides instance-level accessor methods for the Solr connection. By overriding these accessors, applications can provide either custom RSolr clients (e.g. rsolr-async) or per-user or per-controller solr connections:
class CatalogController < ApplicationController
include Blacklight::Catalog
include MyApplicationRuntimeConfiguration
end
module MyApplicationRuntimeConfiguration
def blacklight_solr
@blacklight_solr ||= RSolr::Custom::Client.new :user => current_user.id
end
end