Tirexs v0.8.15 Tirexs.Resources
The intend is to provide an abstraction for dealing with ES resources.
The interface of this module is aware about elasticsearch REST APIs conventions.
Meanwhile, a Tirexs.HTTP
provides just a general interface.
Summary
Functions
Tries to bump resource. This one just makes a request and behaves like a proxy to
one of avalable resource helper. You’re able to bump any resources which are defined in
Tirexs.Resources.APIs
the same as Tirexs.HTTP.head!(path, uri)
expression. See Tirexs.HTTP.head!/2
the same as Tirexs.HTTP.ok?(Tirexs.HTTP.head(path, uri))
expression. See Tirexs.HTTP.ok?/1
and Tirexs.HTTP.head/2
Composes an URN from parts into request ready path as a binary string
Functions
Tries to bump resource. This one just makes a request and behaves like a proxy to
one of avalable resource helper. You’re able to bump any resources which are defined in
Tirexs.Resources.APIs
.
Let’s consider the following use case:
iex> path = Tirexs.Resources.APIs._refresh(["bear_test", "duck_test"], { [force: false] })
"bear_test,duck_test/_refresh?force=false"
iex> Tirexs.HTTP.post(path)
{ :ok, 200, ... }
With bump, the same is:
iex> bump._refresh(["bear_test", "duck_test"], { [force: false] })
{ :ok, 200, ... }
It is also available for bumping some resources with request body:
iex> search = [query: [ term: [ user: "zatvobor" ] ] ]
iex> bump(search)._count("bear_test", "my_type")
{ :ok, 200, ... }
iex> payload = "{ "index": { "_id": "2" }}
{ “title”: “My second blog post” } “
iex> bump(payload)._bulk("website", "blog", { [refresh: true] })
{ :ok, 200, ... }
Play with resources you have and see what kind of HTTP verb is used.
the same as Tirexs.HTTP.head!(path, uri)
expression. See Tirexs.HTTP.head!/2
the same as Tirexs.HTTP.ok?(Tirexs.HTTP.head(path, uri))
expression. See Tirexs.HTTP.ok?/1
and Tirexs.HTTP.head/2
Composes an URN from parts into request ready path as a binary string.
Examples:
iex> urn ["bear_test", "/_alias", ["2015", "2016"]]
"bear_test/_alias/2015,2016"
iex> urn [["bear_test", "another_bear_test"], "_refresh", { [ignore_unavailable: true] }]
"bear_test,another_bear_test/_refresh?ignore_unavailable=true"
iex> urn("bear_test", "bear_type", "10", "_explain?analyzer=some")
"bear_test/bear_type/10/_explain?analyzer=some"
Also see Tirexs.HTTP.url/1
.