Class | ThinkingSphinx::Configuration |
In: |
lib/thinking_sphinx/configuration.rb
|
Parent: | Object |
This class both keeps track of the configuration settings for Sphinx and also generates the resulting file for Sphinx to use.
Here are the default settings, relative to RAILS_ROOT where relevant:
config file: | config/#{environment}.sphinx.conf |
searchd log file: | log/searchd.log |
query log file: | log/searchd.query.log |
pid file: | log/searchd.#{environment}.pid |
searchd files: | db/sphinx/#{environment}/ |
address: | 127.0.0.1 |
port: | 9312 |
allow star: | false |
min prefix length: | 1 |
min infix length: | 1 |
mem limit: | 64M |
max matches: | 1000 |
morphology: | nil |
charset type: | utf-8 |
charset table: | nil |
ignore chars: | nil |
html strip: | false |
html remove elements: | ’’ |
searchd_binary_name: | searchd |
indexer_binary_name: | indexer |
If you want to change these settings, create a YAML file at config/sphinx.yml with settings for each environment, in a similar fashion to database.yml - using the following keys: config_file, searchd_log_file, query_log_file, pid_file, searchd_file_path, port, allow_star, enable_star, min_prefix_len, min_infix_len, mem_limit, max_matches, morphology, charset_type, charset_table, ignore_chars, html_strip, html_remove_elements, delayed_job_priority, searchd_binary_name, indexer_binary_name.
I think you‘ve got the idea.
Each setting in the YAML file is optional - so only put in the ones you want to change.
Keep in mind, if for some particular reason you‘re using a version of Sphinx older than 0.9.8 r871 (that‘s prior to the proper 0.9.8 release), don‘t set allow_star to true.
SourceOptions | = | %w( mysql_connect_flags mysql_ssl_cert mysql_ssl_key mysql_ssl_ca sql_range_step sql_query_pre sql_query_post sql_query_killlist sql_ranged_throttle sql_query_post_index unpack_zlib unpack_mysqlcompress unpack_mysqlcompress_maxsize ) |
IndexOptions | = | %w( blend_chars charset_table charset_type charset_dictpath docinfo enable_star exceptions expand_keywords hitless_words html_index_attrs html_remove_elements html_strip index_exact_words ignore_chars inplace_docinfo_gap inplace_enable inplace_hit_gap inplace_reloc_factor inplace_write_factor min_infix_len min_prefix_len min_stemming_len min_word_len mlock morphology ngram_chars ngram_len ondisk_dict overshort_step phrase_boundary phrase_boundary_step preopen stopwords stopwords_step wordforms ) |
CustomOptions | = | %w( disable_range ) |
allow_star | [RW] | |
app_root | [RW] | |
configuration | [R] | |
controller | [R] | |
database_yml_file | [RW] | |
delayed_job_priority | [RW] | |
environment | [R] | |
index_options | [RW] | |
indexed_models | [RW] | |
model_directories | [RW] | |
searchd_file_path | [RW] | |
source_options | [RW] | |
timeout | [RW] | |
version | [RW] |
Load in the configuration settings - this will look for config/sphinx.yml and parse it according to the current environment.
Generate the config file for Sphinx by using all the settings defined and looping through all the models with indexes to build the relevant indexer and searchd configuration, and sources and indexes details.