elasticsearch v0.1.0 Elasticsearch.Config View Source

Convenience functions for fetching configuration values for Elasticsearch.

Link to this section Summary

Functions

Returns all configuration values for Elasticsearch

Gets the full configuration for a given index

A light wrapper around Application.get_env/2, providing automatic support for {:system, "VAR"} tuples

Returns HTTP basic credential header contents based on the configured :username and :password

Returns the JSON library to use for encoding/decoding. Default: Poison

Returns the configured Elasticsearch URL

Link to this section Functions

Returns all configuration values for Elasticsearch.

Link to this function config_for_index(index) View Source
config_for_index(atom()) ::
  %{settings: String.t(), store: Elasticsearch.Store.t(), sources: [Elasticsearch.Store.source()]} |
  nil

Gets the full configuration for a given index.

Configuration

config :elasticsearch,
  indexes: %{
    posts: %{
      settings: "test/support/settings/posts.json",
      store: Elasticsearch.Test.Store,
      sources: [Post]
    }
  }

Example

iex> Config.config_for_index(:posts)
%{
   settings: "test/support/settings/posts.json",
   store: Elasticsearch.Test.Store,
   sources: [Post]
 }
Link to this function from_env(otp_app, key, default \\ nil) View Source
from_env(atom(), atom(), any()) :: any()

A light wrapper around Application.get_env/2, providing automatic support for {:system, "VAR"} tuples.

Link to this function http_basic_credentials() View Source
http_basic_credentials() :: String.t() | nil

Returns HTTP basic credential header contents based on the configured :username and :password.

Configuration

config :elasticsearch,
  username: "username",
  password: "password"

System tuples are also supported:

config :elasticsearch,
  username: {:system, "ELASTICSEARCH_USERNAME"},
  password: {:system, "ELASTICSEARCH_PASSWORD"}

Example

iex> Config.http_basic_credentials()
"dXNlcm5hbWU6cGFzc3dvcmQ="
Link to this function json_library() View Source
json_library() :: module()

Returns the JSON library to use for encoding/decoding. Default: Poison

Configuration

config :elasticsearch, json_library: Jason

Returns the configured Elasticsearch URL.

Configuration

config :elasticsearch,
  url: "http://localhost:9200"

System tuples are also supported:

config :elasticsearch,
  url: {:system, "ELASTICSEARCH_URL"}

Example

iex> Config.url()
"http://localhost:9200"