View Source Snap.Indexes (Snap v0.11.1)

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.

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

Link to this function

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

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

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

Link to this function

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

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

Deletes older timestamped indexes.

Link to this function

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

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

Creates an index.

Link to this function

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

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

Deletes an index.

Link to this function

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

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

Get an index's mapping.

Link to this function

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

View Source
@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.

Link to this function

list(cluster, opts \\ [])

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

Lists all the indexes in the cluster.

Link to this function

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

View Source
@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.

Link to this function

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

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

Refreshes an index.

Link to this function

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

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

Updates the given index's mapping.