Class: Sunspot::Rails::Configuration
- Inherits:
-
Object
- Object
- Sunspot::Rails::Configuration
- Defined in:
- lib/sunspot/rails/configuration.rb
Overview
Sunspot::Rails is configured via the config/sunspot.yml file, which contains properties keyed by environment name. A sample sunspot.yml file would look like:
development:
solr:
hostname: localhost
port: 8982
test:
solr:
hostname: localhost
port: 8983
production:
solr:
hostname: localhost
port: 8983
path: /solr/myindex
Sunspot::Rails uses the configuration to set up the Solr connection, as well as for starting Solr with the appropriate port using the rake sunspot:solr:start
task.
Instance Attribute Summary collapse
-
#user_configuration ⇒ Object
writeonly
Sets the attribute user_configuration.
Instance Method Summary collapse
-
#auto_commit_after_request? ⇒ Boolean
Should the solr index receive a commit after each http-request.
-
#data_path ⇒ Object
The path to the Solr indexes.
-
#hostname ⇒ Object
The host name at which to connect to Solr.
-
#path ⇒ Object
The url path to the Solr servlet (useful if you are running multicore).
-
#pid_path ⇒ Object
The path to the Solr pids Default RAILS_ROOT + ‘/solr/pids/’ + ENVIRONMENT.
-
#port ⇒ Object
The port at which to connect to Solr.
-
#solr_home ⇒ Object
The path to the Solr home directory Default nil (runs the solr with sunspot default settings).
Instance Attribute Details
#user_configuration=(value) ⇒ Object
Sets the attribute user_configuration
28 29 30 |
# File 'lib/sunspot/rails/configuration.rb', line 28 def user_configuration=(value) @user_configuration = value end |
Instance Method Details
#auto_commit_after_request? ⇒ Boolean
Should the solr index receive a commit after each http-request. Default true
Returns
- Boolean
-
bool
72 73 74 75 |
# File 'lib/sunspot/rails/configuration.rb', line 72 def auto_commit_after_request? @auto_commit_after_request ||= user_configuration_from_key('auto_commit_after_request') != false end |
#data_path ⇒ Object
The path to the Solr indexes. (Used by the rake tasks). Default RAILS_ROOT + ‘/solr/data/’ + ENVIRONMENT
Returns
- String
-
path
85 86 87 |
# File 'lib/sunspot/rails/configuration.rb', line 85 def data_path @data_path ||= user_configuration_from_key('solr', 'data_path') || File.join(::Rails.root, 'solr', 'data', ::Rails.env) end |
#hostname ⇒ Object
The host name at which to connect to Solr. Default ‘localhost’.
Returns
- String
-
host name
36 37 38 |
# File 'lib/sunspot/rails/configuration.rb', line 36 def hostname @hostname ||= (user_configuration_from_key('solr', 'hostname') || 'localhost') end |
#path ⇒ Object
The url path to the Solr servlet (useful if you are running multicore). Default ‘/solr’.
Returns
- String
-
path
59 60 61 |
# File 'lib/sunspot/rails/configuration.rb', line 59 def path @path ||= (user_configuration_from_key('solr', 'path') || '/solr') end |
#pid_path ⇒ Object
The path to the Solr pids Default RAILS_ROOT + ‘/solr/pids/’ + ENVIRONMENT
Returns
- String
-
path
97 98 99 |
# File 'lib/sunspot/rails/configuration.rb', line 97 def pid_path @pids_path ||= user_configuration_from_key('solr', 'pid_path') || File.join(::Rails.root, 'solr', 'pids', ::Rails.env) end |
#port ⇒ Object
The port at which to connect to Solr. Default 8983.
Returns
- Integer
-
port
47 48 49 |
# File 'lib/sunspot/rails/configuration.rb', line 47 def port @port ||= (user_configuration_from_key('solr', 'port') || 8983).to_i end |
#solr_home ⇒ Object
The path to the Solr home directory Default nil (runs the solr with sunspot default settings).
If you have a custom solr conf directory, change this to the directory above your solr conf files
e.g. conf files in RAILS_ROOT/solr/conf
solr_home: RAILS_ROOT/solr
Returns
- String
-
path
115 116 117 118 119 120 121 122 |
# File 'lib/sunspot/rails/configuration.rb', line 115 def solr_home @solr_home ||= if user_configuration_from_key('solr', 'solr_home') user_configuration_from_key('solr', 'solr_home') elsif %w(solrconfig schema).all? { |file| File.exist?(File.join(::Rails.root, 'solr', 'conf', "#{file}.xml")) } File.join(::Rails.root, 'solr') end end |