Configuration

This class is also aliased as Elastics::Conf.

You can configure the elastics gems by changing their configuration settings. You can set them directly in any part of your code or the console like:

Elastics::Configuration.logger.debug_result = true

or setting them inside a Elastics::Configuration.configure block:

Elastics::Configuration.configure do |conf|
  conf.http_client.base_uri = 'http://localhost:9222'
  conf.http_client.options  = {:timeout => 10}
  conf.variables[:index]    = 'my_index'
  ...
end

If you use the rails integration, you usually do so in an initializer, usually generated by the elastics:setup generator (see elastics-rails).

Settings

result_extenders

An array of extender modules. Each gem pushes its default:

# elastics gem
[ Elastics::Result::Document,
  Elastics::Result::Search,
  Elastics::Result::MultiGet,
  Elastics::Result::Bulk ]

# elastics-models gem
[ Elastics::Result::DocumentLoader,
  Elastics::Result::SearchLoader,
  Elastics::Result::ActiveModel ]

# elastics-scopes gem
[ Elastics::Result::Scope ]

You usually push your own extenders to the result_extenders array (see Result Extenders)

ansi

Boolean. If true prints logs and progress bars in colored ANSI. Default true (when supported).

logger

The Elastics logger. Default Logger.new(STDERR)

logger.debug_variables

Boolean. If true it prints the merged variables. Default true unless in Rails Console.

logger.debug_request

Boolean. If true it prints the request. Default true.

logger.debug_result

Boolean. If true it prints also the result. Default true unless in Rails Console.

logger.curl_format

Boolean. If true it uses curl-like logging info, suitable to be copied and pasted in a terminal. Default false (YAML logging).

logger.log_to_rails_logger

This is a specific configuration for the elastics-rails gem.

Boolean. If true it forwards the messages to the Rails.logger. Defaut true unless in Rails Console.

logger.log_to_stdout

This is a specific configuration for the elastics-rails gem.

Boolean. Option added by elastics-rails. If true prints the log to STDOUT. Default false unless in Rails Console.

elastics_models

This is a specific configuration for the elastics-models gem.

An array of model classes (or model class names) that your app will index. This is the only required configuration setting if you use the Elastics::ModelIndexer integration, since it is used to generate the default mappings and the default models for the import task.

elastics_active_models

This is a specific configuration for the elastics-models gem.

An array of ActiveModel classes (or model class names) that your app defines. This is the only required configuration setting if you use the Elastics::ActiveModel integration, since it is used to generate the default mappings.

elastics_dir

The path where Elastics searches for source files. Default './elastics' or "#{Rails.root}/app/elastics" in Rails.

config_file

A YAML file usually containing the custom index mapping. Default './config/elastics.yml' or "#{Rails.root}/config/elastics.yml" in Rails.

http_client

The HTTP client instance. Default an object of class Elastics::HttpClients::Patron or Elastics::HttpClients::RestClient, depending on which gem you have installed (patron or rest-client). If you create a custom client class you must set it.

Temporary Note: The patron gem currently available on rubygem (v0.4.18) is missing the support for sending data with delete queries. As the result it fails with the delete_by_query elasticsearch API, when the query is the request body and not the param. If you want full support until a new version will be pushed to rubygems, you should use gem 'patron', :git => 'https://github.com/patron/patron.git' or switch to the rest-client gem.

http_client.base_uri

The base uri of the elasticsearch server used for all the requests. Default 'http://localhost:9200'.

http_client.options

Hash of options passed to the http_client#new method. Default {}.

http_client.raise_proc

This variable is experimental and may be removed in a next vesion.

A proc that should return whether or not to raise an error, depending on the response. It is used for example to decide whether a 404 response code should raise an error or should just be ignored. Default proc{|respose| response.status >= 400}

variables

The Elastics::Variable object (Hash subclass) of interpolation variables used as the lowest default level. Default:

Elastics::Variables.new :index      => nil,
                        :type       => nil,
                        :params     => {},
                        :no_pruning => []

The elastics-rails gem sets the default variables[:index] as the app_id (see below).

(see Variables)

app_id

An unique string used to identify your app. Default: nil or the uderscored rails application name, plus the environment in rails. It must be set if you use any reindex method. Used by the elastics-reindex feature (see Live Reindex).

optimize_indexing

Boolean. Option added by elastics-admin. If true it optimizes the new indices. Default true.

redis

The redis client object. Default: $redis || Redis.current. Used by the live-reindex feature (see Live Reindex).

on_stop_indexing

A proc that should ensure to stop/suspend all the actions that would produce any change in the indices being live-reindexed. Used by the live-reindex feature and overridden by the on_stop_indexing block (see onstopindexing).