Skip to content
A minimalistic Elasticsearch client for Elixir.
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.credo.exs
.formatter.exs
.gitignore
.tool-versions
.travis.yml
LICENSE
README.md
coveralls.json
mix.exs
mix.lock

README.md

ESClient

Build Status Coverage Status Hex.pm

A minimalistic Elasticsearch client for Elixir.

Prerequisites

  • Elixir >= 1.8
  • Erlang >= 20

Installation

If available in Hex, the package can be installed by adding es_client to your list of dependencies in mix.exs:

def deps do
  [
    {:es_client, "~> 0.1"},

    # You will also need a JSON library
    {:jason, "~> 1.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/es_client.

Usage

You can call the client directly if you have a config struct.

config = %ESClient.Config{base_url: "http://localhost:9201"}
ESClient.get!(config, "_cat/health")

It's also possible to pass a list of path segments.

ESClient.get!(config, ["_cat", "health"])

When the location is a tuple, the second element becomes encoded as query params.

ESClient.get!(config, {["_cat", "health"], verbose: true})

Or you can use this module to build your own custom client and obtain values from the application config.

defmodule MyCustomClient
  use ESClient, otp_app: :my_app
end

Don't forget to add the configuration to your config.exs.

use Mix.Config
# or
import Config

config :my_app, MyCustomClient,
  base_url: "http://localhost:9201",
  json_keys: :atoms,
  json_library: Jason,
  timeout: 15_000

Then, use your client.

MyCustomClient.get!("_cat/health")

Missing Features

  • Authentication
You can’t perform that action at this time.