Skip to content

wlchn/elixir_elastic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElixirElastic

A simple Elixir Elasticsearch HTTP client.

Installation

  1. Add elixir_elastic to your list of dependencies in mix.exs:
def deps do
  [{:elixir_elastic, "~> 0.1.0"}]
end
  1. Ensure elixir_elastic is started before your application:
def application do
  [applications: [:elixir_elastic]]
end

Configuration

In config/dev.exs, configure elixir_elastic:

# The default uri is http://127.0.0.1:9200
config :elixir_elastic, :uri, "http://127.0.0.1:9200"

Usage

  1. Index a document:
import ElixirElastic

put("/my_index/articles/1", [title: "faded", content: "You were the shadow to my light ..."])
# {:ok, 201,
#  %{_id: "1", _index: "my_index", _type: "articles", _version: 1, created: true}}
  1. Fetch the document:
get("/my_index/articles/1")
#  {:ok, 200,
#   %{_id: "1", _index: "my_index",
#     _source: %{content: "You were the shadow to my light ...", title: "faded"}, _type: "articles",
#     _version: 1, found: true}}
  1. Simplified search:
get("/my_index/articles/_search?q=title:faded")
#  {:ok, 200,
#   %{_shards: %{failed: 0, successful: 5, total: 5},
#     hits: %{hits: [%{_id: "1", _index: "my_index", _score: 0.35987286,
#          _source: %{content: "You were the shadow to my light ...", title: "faded"}, _type: "articles"}],
#       max_score: 0.35987286, total: 1}, timed_out: false, took: 10}}

About

A simple Elixir Elasticsearch HTTP client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages