Configuration

This class is also aliased as Flex::Conf.

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

Flex::Configuration.logger.debug_result = true

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

Flex::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 flex:setup generator (see flex-rails).

Settings

result_extenders

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

# flex gem
[ Flex::Result::Document,
  Flex::Result::Search,
  Flex::Result::MultiGet,
  Flex::Result::Bulk ]

# flex-models gem
[ Flex::Result::DocumentLoader,
  Flex::Result::SearchLoader,
  Flex::Result::ActiveModel ]

# flex-scopes gem
[ Flex::Result::Scope ]

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

logger

The Flex logger. Default Logger.new(STDERR)

logger.color

Boolean. If true prints the log in color. Default true (when supported).

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 flex-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 flex-rails gem.

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

flex_models

This is a specific configuration for the flex-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 Flex::ModelIndexer integration, since it is used to generate the default mappings and the default models for the import task.

flex_active_models

This is a specific configuration for the flex-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 Flex::ActiveModel integration, since it is used to generate the default mappings.

flex_dir

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

config_file

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

http_client

The flex client instance. Default an object of class Flex::HttpClients::Patron or Flex::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', '0.4.18', :git => 'https://github.com/ddnexus/patron.git' or download patron-0.4.18.flex.gem, install it with gem install /path/to/patron-0.4.18.flex.gem --local and be sure your app will use that version, 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 Flex::Variable object (Hash subclass) of interpolation variables used as the lowest default level. Default:

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

The flex-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 flex-reindex feature (see Live Reindex).

redis

The redis client object. Default: $redis || Redis.current. Used by the flex-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 flex-reindex feature and overridden by the on_stop_indexing block (see on_stop_indexing).