• Stars
    star
    162
  • Rank 224,043 (Top 5 %)
  • Language
    Erlang
  • License
    GNU Lesser Genera...
  • Created about 14 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Erlang app for communicating with Elastic Search's rest interface.

ErlasticSearch

An Erlang client for Elasticsearch.

Build and Run

Start a rebar3 shell

rebar3 shell

Create an index :

erlastic_search:create_index(<<"index_name">>).
{ok, [{<<"ok">>,true},{<<"acknowledged">>,true}]}

Index a document :

erlastic_search:index_doc(<<"index_name">>, <<"type">>, [{<<"key1">>, <<"value1">>}]).
{ok,[{<<"ok">>,true},
     {<<"_index">>,<<"index_name">>},
     {<<"_type">>,<<"type">>},
     {<<"_id">>,<<"T-EzM_yeTkOEHPL9cN5B2g">>},
     {<<"_version">>,1}]}

Index a document (providing a document id) :

erlastic_search:index_doc_with_id(<<"index_name">>, <<"type">>, <<"id1">>, [{<<"key1">>, <<"value1">>}]).
{ok,[{<<"ok">>,true},
     {<<"_index">>,<<"index_name">>},
     {<<"_type">>,<<"type">>},
     {<<"_id">>,<<"id1">>},
     {<<"_version">>,2}]}

Search for a document :

erlastic_search:search(<<"index_name">>, <<"type">>, <<"key1:value1">>).
{ok,[{<<"took">>,6},
     {<<"timed_out">>,false},
     {<<"_shards">>,
      [{<<"total">>,5},{<<"successful">>,5},{<<"failed">>,0}]},
     {<<"hits">>,
      [{<<"total">>,3},
       {<<"max_score">>,0.30685282},
       {<<"hits">>,
        [[{<<"_index">>,<<"index_name">>},
          {<<"_type">>,<<"type">>},
          {<<"_id">>,<<"T-EzM_yeTkOEHPL9cN5B2g">>},
          {<<"_score">>,0.30685282},
          {<<"_source">>,[{<<"key1">>,<<"value1">>}]}],
         [{<<"_index">>,<<"index_name">>},
          {<<"_type">>,<<"type">>},
          {<<"_id">>,<<"id1">>},
          {<<"_score">>,0.30685282},
          {<<"_source">>,[{<<"key1">>,<<"value1">>}]}],
         [{<<"_index">>,<<"index_name">>},
          {<<"_type">>,<<"type">>},
          {<<"_id">>,<<"MMNcfNHUQyeizDkniZD2bg">>},
          {<<"_score">>,0.30685282},
          {<<"_source">>,[{<<"key1">>,<<"value1">>}]}]]}]}]}

Testing

In another terminal use docker-compose to start an Elasticsearch instance :

docker-compose up

For convenience, you can also start a Kibana instance for analysis/visualization :

docker-compose -f docker-compose.yml -f docker-compose-kibana.yml up

Run Common Test:

rebar3 ct

Using another JSON library than jsx

By default, we assume all the JSON erlang objects passed to us are in jsx's representation. And similarly, all of Elasticsearch's replies will be decoded with jsx.

However, you might already be using another JSON library in your project, which might encode and decode JSONs from and to a different erlang representation. For example, jiffy:

1> SimpleJson = <<"{\"key\":\"value\"}">>.
<<"{\"key\":\"value\"}">>
2> jiffy:decode(SimpleJson).
{[{<<"key">>,<<"value">>}]}
3> jsx:decode(SimpleJson).
[{<<"key">>,<<"value">>}]

In that case, you probably want erlastic_search to use your JSON representation of choice instead of jsx's.

You can do so by defining the ERLASTIC_SEARCH_JSON_MODULE environment variable when compiling erlastic_search, for example:

export ERLASTIC_SEARCH_JSON_MODULE=jiffy
rebar compile

The only constraint is that ERLASTIC_SEARCH_JSON_MODULE should be the name of a module, in your path, that defines the two following callbacks:

-callback encode(erlastic_json()) -> binary().
-callback decode(binary()) -> erlastic_json().

where erlastic_json() is a type mapping to your JSON representation of choice.

More Repositories

1

epmdless

Distributed Erlang without the EPMD
Erlang
173
star
2

grpcbox

Erlang grpc on chatterbox
Erlang
133
star
3

kuberl

Erlang Kubernetes client
Erlang
53
star
4

erl_tidy

Automatically format Erlang code.
Erlang
47
star
5

epubnub

Erlang PubNub API
Erlang
28
star
6

OpaDo

Opa port of the TodoMVC app
Opa
23
star
7

rebar3_run

Run a release with one simple command
Makefile
23
star
8

augle

Auth + Google = Augle
Erlang
22
star
9

grafana-operator

Grafana Operator creates and manages Grafana deployments on Kubernetes.
Go
18
star
10

eCloudEdit

A port of CloudEdit to use Webmachine instead of Rails
JavaScript
16
star
11

sctp_dist

Erlang
16
star
12

epmdlessless

Erlang
15
star
13

ramler

Erlang generators for RAML
Erlang
14
star
14

pg_types

Erlang library for encoding and decoding postgres data types
Erlang
13
star
15

erlup

Erlang toolchain installer
Rust
13
star
16

eindexer

Simple search engine written in Erlang
Erlang
12
star
17

throttle

Library for checking if a process is overloaded
Erlang
11
star
18

rebar3_erlydtl_plugin

Rebar3 Erlydtl Plugin
Erlang
11
star
19

ctx

Erlang context library
Erlang
10
star
20

vanguard

Discover Cadre in the Vanguard
Erlang
10
star
21

dynamo_heroku_demo

Sample Heroku app for Elixir web framework Dynamo
Elixir
10
star
22

providers

Providers provide.
Erlang
10
star
23

jsonlog

A custom formatter for the Erlang logger that converts logs to json
Erlang
10
star
24

beerenthusiasts

Beer Enthusiasts is the easiest way to share, discuss and discover new recipes for homebrewing beer. Built using Erlang, Yaws, Nitrogen and CouchDB.
JavaScript
10
star
25

rebar3.org

Rebar3.org
CSS
9
star
26

erls

Build and manage multiple Erlang versions
Rust
9
star
27

grpcbox_plugin

Rebar3 plugin for generating grpcbox behaviours
Erlang
9
star
28

egit_sshd

SSH dameon for hosting git repos
Erlang
7
star
29

docker_compose_cth

Erlang Common Test Hook for starting docker-compose services before running test suites
Erlang
7
star
30

rebar_docker

rebar3 plugin for generating docker images
Erlang
7
star
31

heroku_weber_example

Weber example for Heroku
Elixir
7
star
32

elna

Erlang HTTP 1.1 and 2 server using Elli and Chatterbox
Erlang
6
star
33

heroku-buildpack-opa

Opa buildpack for Heroku
Shell
6
star
34

otel_getting_started

Erlang
6
star
35

mirrormaster

Hex mirror and private repo
Erlang
6
star
36

kakapo

riak_core based router
Erlang
6
star
37

wts

Warping the Timestamps
Erlang
6
star
38

erlangdc2013

Erlang on Heroku Workshop ErlangDC 2013
Erlang
5
star
39

rebar3_tests

Rebar3 ShellTestRunner tests
Erlang
5
star
40

mmmbot

Erlang Irc bot
Erlang
5
star
41

chatterbox_tiles

Erlang
5
star
42

epubnub_chat

And example for using epubnub to talk to the example chat app on http://www.pubnub.com/blog/build-real-time-web-apps-easy
Erlang
5
star
43

rebar_alias

Rebar3 plugin for defining aliases
Erlang
5
star
44

cs542-prims-algorithm

CS542 Project: Implementation of Prim's Algorithm
Erlang
4
star
45

dwight

Hermes' son
Erlang
4
star
46

webmachine_examples

Webmachine Examples
Erlang
4
star
47

rebar_publish

Publish apps
Erlang
4
star
48

postgres_pool_example

Erlang Postgres Connection Pool Example
Erlang
4
star
49

logfmt-erlang

Logfmt log parsing for Erlang
Erlang
4
star
50

cowboy_template

Cowboy app template
Erlang
4
star
51

erlchestrate

Erlang client for orchestrate.io
Erlang
4
star
52

rebar3_elixirc

Erlang
4
star
53

elli_chatterbox

Combine Elli and Chatterbox into one http monster
Erlang
4
star
54

odoric

Odoric
Erlang
3
star
55

elli_template

Elli template for Rebar3
Erlang
3
star
56

opa_pubnub_plugin

Opa plugin for client side interaction with PubNub
JavaScript
3
star
57

rebar3_ex_compiler

Example rebar3 compile provider
Erlang
3
star
58

ceug_4_2012

Chicago Erlang User Group April, 2012 Presentation on Cowboy and Batman.js
3
star
59

CEUG

Chicago Erlang User Group Demos
JavaScript
3
star
60

session_8

ErlangCamp Session 8
Erlang
3
star
61

riak_pb_msgcodegen

Erlang
3
star
62

roll_dice

Dice rolling OpenTelemetry Erlang example
Erlang
2
star
63

erlanger_evolution

The evolution of an erlang programmer. From non-OTP to OTP.
Erlang
2
star
64

rebar3_orb

Orb for building and testing rebar3 projects in CircleCI
2
star
65

kustomize-git-ref-transformer

Kustomize transformer to replace an image tag with the current git reference
Shell
2
star
66

lambda_jam_2013

Lambda Jam 2013 Presentation
Ruby
2
star
67

erl_new

Script for Erlang templates
Shell
2
star
68

ember_template

Erlang Ember App Template
JavaScript
1
star
69

lambda_jam_2013_maze

Maze
Erlang
1
star
70

heroku-buildpack-erlang-dialyzer

Run Dialyzer on your project and host the results
Shell
1
star
71

seresye.agner

Seresye package
1
star
72

eMmmbot

New mmmbot web interface and backend
JavaScript
1
star
73

gen_leader_zk

Erlang
1
star
74

county

Sheriff patrols the County
Erlang
1
star
75

erlangdc2013_workshop

Workshop for ErlangDC2013
Ruby
1
star
76

reports

JavaScript
1
star
77

orchestrate-erlang-client

A super simple (more planned) Erlang client to query the Orchestrate.io service.
Erlang
1
star
78

elenchus

JavaScript
1
star
79

dep_tracking

Dependency tracking example for rebar3
Erlang
1
star
80

jqheroku

Webapp to fetch json from a url and run a jsonpath against it
Erlang
1
star
81

mashape-erlang-client-library

Mashape Erlang client library
Erlang
1
star
82

erlware_commons.agner

Erlware Commons agner package
1
star