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
min_memory: 512M
max_memory: 1G
solr_jar: /some/path/solr15/start.jar
test:
solr:
hostname: localhost
port: 8983
log_level: OFF
production:
solr:
hostname: localhost
port: 8983
path: /solr/myindex
log_level: WARNING
solr_home: /some/path
master_solr:
hostname: localhost
port: 8982
path: /solr
auto_commit_after_request: true
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.
If the master_solr
configuration is present, Sunspot will use the Solr instance specified here for all write operations, and the Solr configured under solr
for all read operations.
Instance Attribute Summary collapse
-
#user_configuration ⇒ Object
writeonly
Sets the attribute user_configuration.
Instance Method Summary collapse
-
#auto_commit_after_delete_request? ⇒ Boolean
As for #auto_commit_after_request? but only for deletes Default false.
-
#auto_commit_after_request? ⇒ Boolean
Should the solr index receive a commit after each http-request.
- #data_path ⇒ Object
-
#has_master? ⇒ Boolean
True if there is a master Solr instance configured, otherwise false.
-
#hostname ⇒ Object
The host name at which to connect to Solr.
-
#log_file ⇒ Object
The log directory for solr logfiles.
-
#log_level ⇒ Object
The default log_level that should be passed to solr.
-
#master_hostname ⇒ Object
The host name at which to connect to the master Solr instance.
-
#master_path ⇒ Object
The path to the master Solr servlet (useful if you are running multicore).
-
#master_port ⇒ Object
The port at which to connect to the master Solr instance.
-
#max_memory ⇒ Object
Maximum java heap size for Solr instance.
-
#min_memory ⇒ Object
Minimum java heap size for Solr instance.
-
#path ⇒ Object
The url path to the Solr servlet (useful if you are running multicore).
- #pid_path ⇒ Object
-
#port ⇒ Object
The port at which to connect to Solr.
-
#solr_home ⇒ Object
The solr home directory.
-
#solr_jar ⇒ Object
Solr start jar.
Instance Attribute Details
#user_configuration=(value) ⇒ Object
Sets the attribute user_configuration
42 43 44 |
# File 'lib/sunspot/rails/configuration.rb', line 42 def user_configuration=(value) @user_configuration = value end |
Instance Method Details
#auto_commit_after_delete_request? ⇒ Boolean
As for #auto_commit_after_request? but only for deletes Default false
Returns
Boolean: auto_commit_after_delete_request?
158 159 160 161 |
# File 'lib/sunspot/rails/configuration.rb', line 158 def auto_commit_after_delete_request? @auto_commit_after_delete_request ||= (user_configuration_from_key('auto_commit_after_delete_request') || false) end |
#auto_commit_after_request? ⇒ Boolean
Should the solr index receive a commit after each http-request. Default true
Returns
Boolean: auto_commit_after_request?
145 146 147 148 |
# File 'lib/sunspot/rails/configuration.rb', line 145 def auto_commit_after_request? @auto_commit_after_request ||= user_configuration_from_key('auto_commit_after_request') != false end |
#data_path ⇒ Object
175 176 177 |
# File 'lib/sunspot/rails/configuration.rb', line 175 def data_path @data_path ||= user_configuration_from_key('solr', 'data_path') || File.join(::Rails.root, 'solr', 'data', ::Rails.env) end |
#has_master? ⇒ Boolean
True if there is a master Solr instance configured, otherwise false.
Returns
- Boolean
-
bool
120 121 122 |
# File 'lib/sunspot/rails/configuration.rb', line 120 def has_master? @has_master = !!user_configuration_from_key('master_solr') end |
#hostname ⇒ Object
The host name at which to connect to Solr. Default ‘localhost’.
Returns
- String
-
host name
50 51 52 |
# File 'lib/sunspot/rails/configuration.rb', line 50 def hostname @hostname ||= (user_configuration_from_key('solr', 'hostname') || 'localhost') end |
#log_file ⇒ Object
The log directory for solr logfiles
Returns
- String
-
log_dir
171 172 173 |
# File 'lib/sunspot/rails/configuration.rb', line 171 def log_file @log_file ||= (user_configuration_from_key('solr', 'log_file') || default_log_file_location ) end |
#log_level ⇒ Object
The default log_level that should be passed to solr. You can change the individual log_levels in the solr admin interface. Default ‘INFO’.
Returns
- String
-
log_level
133 134 135 |
# File 'lib/sunspot/rails/configuration.rb', line 133 def log_level @log_level ||= (user_configuration_from_key('solr', 'log_level') || 'INFO') end |
#master_hostname ⇒ Object
The host name at which to connect to the master Solr instance. Defaults to the ‘hostname’ configuration option.
Returns
- String
-
host name
85 86 87 |
# File 'lib/sunspot/rails/configuration.rb', line 85 def master_hostname @master_hostname ||= (user_configuration_from_key('master_solr', 'hostname') || hostname) end |
#master_path ⇒ Object
The path to the master Solr servlet (useful if you are running multicore). Defaults to the value of the ‘path’ configuration option.
Returns
- String
-
path
109 110 111 |
# File 'lib/sunspot/rails/configuration.rb', line 109 def master_path @master_path ||= (user_configuration_from_key('master_solr', 'path') || path) end |
#master_port ⇒ Object
The port at which to connect to the master Solr instance. Defaults to the ‘port’ configuration option.
Returns
- Integer
-
port
97 98 99 |
# File 'lib/sunspot/rails/configuration.rb', line 97 def master_port @master_port ||= (user_configuration_from_key('master_solr', 'port') || port).to_i end |
#max_memory ⇒ Object
Maximum java heap size for Solr instance
218 219 220 |
# File 'lib/sunspot/rails/configuration.rb', line 218 def max_memory @max_memory ||= user_configuration_from_key('solr', 'max_memory') end |
#min_memory ⇒ Object
Minimum java heap size for Solr instance
211 212 213 |
# File 'lib/sunspot/rails/configuration.rb', line 211 def min_memory @min_memory ||= user_configuration_from_key('solr', 'min_memory') end |
#path ⇒ Object
The url path to the Solr servlet (useful if you are running multicore). Default ‘/solr’.
Returns
- String
-
path
73 74 75 |
# File 'lib/sunspot/rails/configuration.rb', line 73 def path @path ||= (user_configuration_from_key('solr', 'path') || '/solr') end |
#pid_path ⇒ Object
179 180 181 |
# File 'lib/sunspot/rails/configuration.rb', line 179 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
61 62 63 |
# File 'lib/sunspot/rails/configuration.rb', line 61 def port @port ||= (user_configuration_from_key('solr', 'port') || 8983).to_i end |
#solr_home ⇒ Object
The solr home directory. Sunspot::Rails expects this directory to contain a config, data and pids directory. See Sunspot::Rails::Server.bootstrap for more information.
Returns
- String
-
solr_home
192 193 194 195 196 197 198 199 |
# File 'lib/sunspot/rails/configuration.rb', line 192 def solr_home @solr_home ||= if user_configuration_from_key('solr', 'solr_home') user_configuration_from_key('solr', 'solr_home') else File.join(::Rails.root, 'solr') end end |
#solr_jar ⇒ Object
Solr start jar
204 205 206 |
# File 'lib/sunspot/rails/configuration.rb', line 204 def solr_jar @solr_jar ||= user_configuration_from_key('solr', 'solr_jar') end |