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

bump()

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.

bump(uri)
bump(body, uri)
bump!()
bump!(uri)
bump!(body, uri)
exists!(url_or_path_or_uri)
exists!(path, uri)

the same as Tirexs.HTTP.head!(path, uri) expression. See Tirexs.HTTP.head!/2

exists?(url_or_path_or_uri)
exists?(path, uri)

the same as Tirexs.HTTP.ok?(Tirexs.HTTP.head(path, uri)) expression. See Tirexs.HTTP.ok?/1 and Tirexs.HTTP.head/2

urn(part)

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.

urn(a, b)
urn(a, b, c)
urn(a, b, c, d)
urn(a, b, c, d, e)
urn(a, b, c, d, e, f)
urn(a, b, c, d, e, f, g)