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 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.
Methods
public instance
Attributes
user_configuration | [W] |
Public instance methods
As for auto_commit_after_request? but only for deletes Default false
Returns
Boolean: auto_commit_after_delete_request?
# File lib/sunspot/rails/configuration.rb, line 157 def auto_commit_after_delete_request? @auto_commit_after_delete_request ||= (user_configuration_from_key('auto_commit_after_delete_request') || false) end
Should the solr index receive a commit after each http-request. Default true
Returns
Boolean: auto_commit_after_request?
# File lib/sunspot/rails/configuration.rb, line 144 def auto_commit_after_request? @auto_commit_after_request ||= user_configuration_from_key('auto_commit_after_request') != false end
# File lib/sunspot/rails/configuration.rb, line 174 def data_path @data_path ||= user_configuration_from_key('solr', 'data_path') || File.join(::Rails.root, 'solr', 'data', ::Rails.env) end
True if there is a master Solr instance configured, otherwise false.
Returns
Boolean: | bool |
# File lib/sunspot/rails/configuration.rb, line 119 def has_master? @has_master = !!user_configuration_from_key('master_solr') end
The host name at which to connect to Solr. Default ‘localhost’.
Returns
String: | host name |
# File lib/sunspot/rails/configuration.rb, line 49 def hostname @hostname ||= (user_configuration_from_key('solr', 'hostname') || 'localhost') end
The log directory for solr logfiles
Returns
String: | log_dir |
# File lib/sunspot/rails/configuration.rb, line 170 def log_file @log_file ||= (user_configuration_from_key('solr', 'log_file') || default_log_file_location ) end
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 |
# File lib/sunspot/rails/configuration.rb, line 132 def log_level @log_level ||= (user_configuration_from_key('solr', 'log_level') || 'INFO') end
The host name at which to connect to the master Solr instance. Defaults to the ‘hostname’ configuration option.
Returns
String: | host name |
# File lib/sunspot/rails/configuration.rb, line 84 def master_hostname @master_hostname ||= (user_configuration_from_key('solr', 'master_hostname') || hostname) end
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 |
# File lib/sunspot/rails/configuration.rb, line 108 def master_path @master_path ||= (user_configuration_from_key('solr', 'master_path') || path) end
The port at which to connect to the master Solr instance. Defaults to the ‘port’ configuration option.
Returns
Integer: | port |
# File lib/sunspot/rails/configuration.rb, line 96 def master_port @master_port ||= (user_configuration_from_key('solr', 'master_port') || port).to_i end
Maximum java heap size for Solr instance
# File lib/sunspot/rails/configuration.rb, line 210 def max_memory @max_memory ||= user_configuration_from_key('solr', 'max_memory') end
Minimum java heap size for Solr instance
# File lib/sunspot/rails/configuration.rb, line 203 def min_memory @min_memory ||= user_configuration_from_key('solr', 'min_memory') end
The url path to the Solr servlet (useful if you are running multicore). Default ’/solr’.
Returns
String: | path |
# File lib/sunspot/rails/configuration.rb, line 72 def path @path ||= (user_configuration_from_key('solr', 'path') || '/solr') end
# File lib/sunspot/rails/configuration.rb, line 178 def pid_path @pids_path ||= user_configuration_from_key('solr', 'pid_path') || File.join(::Rails.root, 'solr', 'pids', ::Rails.env) end
The port at which to connect to Solr. Default 8983.
Returns
Integer: | port |
# File lib/sunspot/rails/configuration.rb, line 60 def port @port ||= (user_configuration_from_key('solr', 'port') || 8983).to_i end
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 |
# File lib/sunspot/rails/configuration.rb, line 191 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