Method: Chewy::Config#configuration

Defined in:
lib/chewy/config.rb

#configurationObject

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:

  1. Chewy client options. All the options Elasticsearch::Client supports.

    test: host: 'localhost:9250'

  2. 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

  3. 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