Class: Chewy::Config
Instance Attribute Summary collapse
- 
  
    
      #before_es_request_filter  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute before_es_request_filter. 
- 
  
    
      #console_strategy  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute console_strategy. 
- 
  
    
      #default_field_type  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute default_field_type. 
- 
  
    
      #default_root_options  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute default_root_options. 
- 
  
    
      #disable_refresh_async  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute disable_refresh_async. 
- 
  
    
      #import_scope_cleanup_behavior  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute import_scope_cleanup_behavior. 
- 
  
    
      #indices_path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute indices_path. 
- 
  
    
      #logger  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute logger. 
- 
  
    
      #request_strategy  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute request_strategy. 
- 
  
    
      #reset_disable_refresh_interval  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute reset_disable_refresh_interval. 
- 
  
    
      #reset_no_replicas  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute reset_no_replicas. 
- 
  
    
      #root_strategy  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute root_strategy. 
- 
  
    
      #search_class  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute search_class. 
- 
  
    
      #settings  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute settings. 
- 
  
    
      #transport_logger  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute transport_logger. 
- 
  
    
      #transport_tracer  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute transport_tracer. 
- 
  
    
      #use_after_commit_callbacks  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute use_after_commit_callbacks. 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #configuration  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Chewy core configurations. 
- 
  
    
      #initialize  ⇒ Config 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Config. 
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
| 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # File 'lib/chewy/config.rb', line 56 def initialize @settings = {} @root_strategy = :base @request_strategy = :atomic @console_strategy = :urgent @use_after_commit_callbacks = true @reset_disable_refresh_interval = false @reset_no_replicas = false @disable_refresh_async = false @indices_path = 'app/chewy' @default_root_options = {} @default_field_type = 'text'.freeze @import_scope_cleanup_behavior = :warn @search_class = build_search_class(Chewy::Search::Request) end | 
Instance Attribute Details
#before_es_request_filter ⇒ Object
Returns the value of attribute before_es_request_filter.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def before_es_request_filter @before_es_request_filter end | 
#console_strategy ⇒ Object
Returns the value of attribute console_strategy.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def console_strategy @console_strategy end | 
#default_field_type ⇒ Object
Returns the value of attribute default_field_type.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def default_field_type @default_field_type end | 
#default_root_options ⇒ Object
Returns the value of attribute default_root_options.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def @default_root_options end | 
#disable_refresh_async ⇒ Object
Returns the value of attribute disable_refresh_async.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def disable_refresh_async @disable_refresh_async end | 
#import_scope_cleanup_behavior ⇒ Object
Returns the value of attribute import_scope_cleanup_behavior.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def import_scope_cleanup_behavior @import_scope_cleanup_behavior end | 
#indices_path ⇒ Object
Returns the value of attribute indices_path.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def indices_path @indices_path end | 
#logger ⇒ Object
Returns the value of attribute logger.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def logger @logger end | 
#request_strategy ⇒ Object
Returns the value of attribute request_strategy.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def request_strategy @request_strategy end | 
#reset_disable_refresh_interval ⇒ Object
Returns the value of attribute reset_disable_refresh_interval.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def reset_disable_refresh_interval @reset_disable_refresh_interval end | 
#reset_no_replicas ⇒ Object
Returns the value of attribute reset_no_replicas.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def reset_no_replicas @reset_no_replicas end | 
#root_strategy ⇒ Object
Returns the value of attribute root_strategy.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def root_strategy @root_strategy end | 
#search_class ⇒ Object (readonly)
Returns the value of attribute search_class.
| 48 49 50 | # File 'lib/chewy/config.rb', line 48 def search_class @search_class end | 
#settings ⇒ Object
Returns the value of attribute settings.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def settings @settings end | 
#transport_logger ⇒ Object
Returns the value of attribute transport_logger.
| 48 49 50 | # File 'lib/chewy/config.rb', line 48 def transport_logger @transport_logger end | 
#transport_tracer ⇒ Object
Returns the value of attribute transport_tracer.
| 48 49 50 | # File 'lib/chewy/config.rb', line 48 def transport_tracer @transport_tracer end | 
#use_after_commit_callbacks ⇒ Object
Returns the value of attribute use_after_commit_callbacks.
| 5 6 7 | # File 'lib/chewy/config.rb', line 5 def use_after_commit_callbacks @use_after_commit_callbacks end | 
Class Method Details
.delegated ⇒ Object
| 52 53 54 | # File 'lib/chewy/config.rb', line 52 def self.delegated public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods end | 
Instance Method Details
#configuration ⇒ Object
Chewy core configurations. There is two ways to set it up:
use Chewy.settings= method or, for Rails application,
create config/chewy.yml file. Btw, config/chewy.yml supports
ERB the same way as ActiveRecord's config.
Configuration options:
- Chewy client options. All the options Elasticsearch::Client supports. - test: host: 'localhost:9250' 
- Chewy self-configuration: - :prefix - used as prefix for any index created. - test: host: 'localhost:9250' prefix: test<%= ENV['TEST_ENV_NUMBER'] %> - Then UsersIndex.index_name will be "test42_users" in case TEST_ENV_NUMBER=42 - :wait_for_status - if this option set - chewy actions such as creating or deleting index, importing data will wait for the status specified. Extremely useful for tests under heavy indexes manipulations. - test: host: 'localhost:9250' wait_for_status: green 
- Index settings. All the possible ElasticSearch index settings. Will be merged as defaults with index settings on every index creation. - test: &test host: 'localhost:9250' index: number_of_shards: 1 number_of_replicas: 0 
| 125 126 127 128 129 130 131 | # File 'lib/chewy/config.rb', line 125 def configuration yaml_settings.merge(settings.deep_symbolize_keys).tap do |configuration| configuration[:logger] = transport_logger if transport_logger configuration[:indices_path] ||= indices_path if indices_path configuration.merge!(tracer: transport_tracer) if transport_tracer end end |