# Snap

[![Hex pm](](

Snap is an Elasticsearch client. It provides a flexible, performant API on
top of your Elasticsearch cluster, supporting high level features like
versioned index management, while also providing a convenient interface into
low level operations.

See the full [API docs](

**Disclaimer**: Snap is new and may not be production ready yet.

## Features

- Versioned index management with zero-downtime hotswapping (compatible with [`elasticsearch`](
- Streaming bulk operations
- Connection pooling
- Telemetry events

## Installation

The package can be installed by adding `snap` to your list of dependencies in

def deps do
    {:snap, "~> 0.4"}

Snap supports Elixir 1.9 or later. It might work with earlier versions but is currently untested.

## Usage

Implement your own cluster module, similar to an `Ecto.Repo`:

defmodule MyApp.Cluster do
  use Snap.Cluster, otp_app: :my_app

Configure it:

config :my_app, MyApp.Cluster,
  url: "http://localhost:9200",
  username: "my_username",
  password: "my_password"

Then wire it into your application supervisor:

def start(_type, _args) do
  children = [
    {MyApp.Cluster, []}

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]
  Supervisor.start_link(children, opts)

Now you can perform operations on your cluster:

{:ok, %{"count" => count}} = MyApp.Cluster.get("/my-index/_count")

See the [API documentation]( for more advanced features.