Skip to content
/ snap Public
forked from BOAKRA/snap

An Elasticsearch client for Elixir

License

Notifications You must be signed in to change notification settings

AsgharRaz/snap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 mix.exs:

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

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
end

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)
end

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.

About

An Elasticsearch client for Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%