Snap.Indexes (Snap v0.1.1) View Source

Helper functions around index management.

Link to this section Summary

Functions

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

Deletes older timestamped indexes.

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.

Link to this section Functions

Link to this function

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

View Source

Specs

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

Specs

Deletes older timestamped indexes.

Link to this function

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

View Source

Specs

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

Creates an index.

Link to this function

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

View Source

Specs

Deletes an index.

Link to this function

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

View Source

Specs

hotswap(Enumerable.t(), module(), String.t(), map(), Keyword.t()) ::
  :ok | Snap.Cluster.error()

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.

Link to this function

list(cluster, opts \\ [])

View Source

Specs

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

Specs

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

Specs

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

Refreshes an index.