Snap.Indexes (Snap v0.13.0)

View Source

Helper functions around index management.

Summary

Functions

Creates an alias for a versioned index, removing any existing aliases.

Deletes older timestamped indexes.

Get an index's mapping.

Get an index's setting using a comma separate list or wildcard expression

Get an index's stats using a metric. Metric is a comma separated list of metrics.

Creates and loads a new index, switching the alias to it with zero-downtime.

Lists all the indexes in the cluster.

Lists all the timestamp versioned indexes starting with the prefix.

Updates the given index's mapping.

Functions

alias(cluster, index, alias, opts \\ [])

@spec alias(module(), String.t(), String.t(), Keyword.t()) ::
  :ok | Snap.Cluster.error()

Creates an alias for a versioned index, removing any existing aliases.

cleanup(cluster, alias, preserve \\ 2, opts \\ [])

@spec cleanup(module(), String.t(), non_neg_integer(), Keyword.t()) ::
  :ok | Snap.Cluster.error()

Deletes older timestamped indexes.

close(cluster, index, params \\ [], opts \\ [])

@spec close(module(), String.t(), Keyword.t(), Keyword.t()) :: Snap.Cluster.result()

Closes an open index.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-close.html

create(cluster, index, mapping, opts \\ [])

@spec create(module(), String.t(), map(), Keyword.t()) :: Snap.Cluster.result()

Creates an index.

delete(cluster, index, opts \\ [])

@spec delete(module(), String.t(), Keyword.t()) :: Snap.Cluster.result()

Deletes an index.

get_mapping(cluster, index, opts \\ [])

@spec get_mapping(module(), String.t(), Keyword.t()) :: Snap.Cluster.result()

Get an index's mapping.

get_setting(cluster, index, setting, params \\ [], opts \\ [])

@spec get_setting(module(), String.t(), String.t(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Get an index's setting using a comma separate list or wildcard expression

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html

get_settings(cluster, index, params \\ [], opts \\ [])

@spec get_settings(module(), String.t(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Get all of the index's settings.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html

get_shard_stores(cluster, index, params \\ [], opts \\ [])

@spec get_shard_stores(module(), String.t(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Get an index's shard stores.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html

get_stat(cluster, index, metric, params \\ [], opts \\ [])

@spec get_stat(module(), String.t(), String.t(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Get an index's stats using a metric. Metric is a comma separated list of metrics.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html

get_stats(cluster, index, params \\ [], opts \\ [])

@spec get_stats(module(), String.t(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Get an index's stats.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html

hotswap(stream, cluster, alias, mapping, opts \\ [])

@spec hotswap(Enumerable.t(), module(), String.t(), map(), Keyword.t()) ::
  :ok | Snap.Cluster.error() | {:error, Snap.BulkError.t()}

Creates and loads a new index, switching the alias to it with zero-downtime.

Takes an Enumerable of Snap.Bulk actions, and builds a new index from it. Refreshes it, updates the alias to it, and cleans up the old indexes, leaving the previous one behind.

May return Snap.Cluster.error/0 or a Snap.BulkError containing a list of failed bulk actions.

list(cluster, opts \\ [])

@spec list(module(), Keyword.t()) :: {:ok, [String.t()]} | Snap.Cluster.error()

Lists all the indexes in the cluster.

list_starting_with(cluster, prefix, opts \\ [])

@spec list_starting_with(module(), String.t(), Keyword.t()) ::
  {:ok, [String.t()]} | Snap.Cluster.error()

Lists all the timestamp versioned indexes starting with the prefix.

open(cluster, index, params \\ [], opts \\ [])

@spec open(module(), String.t(), Keyword.t(), Keyword.t()) :: Snap.Cluster.result()

Opens a closed index.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html

refresh(cluster, index, opts \\ [])

@spec refresh(cluster :: module(), index :: String.t(), opts :: Keyword.t()) ::
  :ok | Snap.Cluster.error()

Refreshes an index.

update_mapping(cluster, index, mapping, opts \\ [])

@spec update_mapping(module(), String.t(), map(), Keyword.t()) ::
  Snap.Cluster.result()

Updates the given index's mapping.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html

update_settings(cluster, index, settings, params \\ [], opts \\ [])

@spec update_settings(module(), String.t(), map(), Keyword.t(), Keyword.t()) ::
  Snap.Cluster.result()

Update an index's settings.

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html