Dowser. Opensearch. IndexTemplate
(Dowser.Opensearch v0.1.0)
View Source
The OpenSearch index template APIs — the endpoints tagged Index Templates in
the OpenSearch OpenAPI specification.
Built on Dowser.Client. Required OpenSearch attributes are positional
arguments; everything optional lives in opts.
OpenSearch tags these separately from the index APIs, so they live here
rather than on Dowser.Opensearch.Index.
The three kinds of template
The tag covers three families, and they are not interchangeable:
- Index templates (
/_index_template) — the composable kind, which can pull shared pieces in throughcomposed_of. This is what to use. - Component templates (
/_component_template) — the reusable pieces an index template composes. They apply nothing on their own. - Legacy templates (
/_template) — the pre-composable kind, kept for compatibility.put_template/3and friends are these; preferput_index_template/3for anything new.
A composable index template always wins over a legacy one matching the same
pattern, whatever its order.
Shared conventions
- A template
nameis a required path parameter, and may be several names (joined with,) on the read endpoints. - Endpoints that accept a request body take it as their first argument,
required — pass
%{}to send nothing. HEADexistence checks come as a pair where the?variant plays the bang role:index_template_exists/2returns{:ok, boolean()}or{:error, exception},index_template_exists?/2returns the bare boolean (404→false) and raises on genuine errors.
All remaining options are forwarded to Dowser.Client.request/4, e.g.
:context, :params (query-string parameters), :format, :keys and
:http_opts (including :headers) — plus :codec, this package's own,
which picks the per-field codec for this one request (see
Dowser.Opensearch.Codec).
On a 2xx response every function returns {:ok, body} with the decoded
response body. A non-2xx response returns
{:error, %Dowser.Opensearch.Error{}}; a transport, encoding or decoding
failure returns {:error, exception} from Dowser.Client. A required
argument that is missing or empty is reported the same way, before any
request is made: {:error, %ArgumentError{}}. Each function has a bang
variant that returns the body directly or raises the error exception.
Summary
Functions
Checks whether the component template name exists.
Like component_template_exists/2, but returns the boolean directly
(404 → false) or raises the error exception.
Deletes the component template name
(Delete component template API).
Like delete_component_template/2, but returns the body directly or raises
the error exception.
Deletes the index template name
(Delete index template API).
Like delete_index_template/2, but returns the body directly or raises the
error exception.
Deletes the legacy index template name
(Delete template API).
Like delete_template/2, but returns the body directly or raises the error
exception.
Returns one, several, or all component templates (Get component template API).
Like get_component_template/1, but returns the body directly or raises the
error exception.
Returns one, several, or all index templates (Get index template API).
Like get_index_template/1, but returns the body directly or raises the
error exception.
Returns one, several, or all legacy index templates (Get template API).
Like get_template/1, but returns the body directly or raises the error
exception.
Checks whether the index template name exists.
Like index_template_exists/2, but returns the boolean directly
(404 → false) or raises the error exception.
Creates or updates the component template name
(Create or update component template API).
Like put_component_template/3, but returns the body directly or raises the
error exception.
Creates or updates the index template name
(Create or update index template API).
Like put_index_template/3, but returns the body directly or raises the
error exception.
Creates or updates the legacy index template name
(Create or update template API).
Like put_template/3, but returns the body directly or raises the error
exception.
Simulates applying the matching index templates to the index name
(Simulate index API).
Like simulate_index_template/3, but returns the body directly or raises
the error exception.
Simulates the resolved composition of an index template (Simulate template API).
Like simulate_template/2, but returns the body directly or raises the
error exception.
Checks whether the legacy index template name exists.
Like template_exists/2, but returns the boolean directly (404 → false)
or raises the error exception.
Types
@type body() :: term()
@type exists_result() :: {:ok, boolean()} | {:error, Exception.t()}
@type name() :: Dowser.Opensearch.Target.name()
@type result() :: {:ok, body()} | {:error, Exception.t()}
Functions
@spec component_template_exists(name(), keyword()) :: exists_result()
Checks whether the component template name exists.
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Like component_template_exists/2, but returns the boolean directly
(404 → false) or raises the error exception.
Deletes the component template name
(Delete component template API).
Like delete_component_template/2, but returns the body directly or raises
the error exception.
Deletes the index template name
(Delete index template API).
Like delete_index_template/2, but returns the body directly or raises the
error exception.
Deletes the legacy index template name
(Delete template API).
Like delete_template/2, but returns the body directly or raises the error
exception.
Returns one, several, or all component templates (Get component template API).
Options
:name— restrict the result to one or several template names; absent for all of them.
Like get_component_template/1, but returns the body directly or raises the
error exception.
Returns one, several, or all index templates (Get index template API).
Options
:name— restrict the result to one or several template names, which may include wildcards; absent for all of them.
Like get_index_template/1, but returns the body directly or raises the
error exception.
Returns one, several, or all legacy index templates (Get template API).
Options
:name— restrict the result to one or several template names; absent for all of them.
Like get_template/1, but returns the body directly or raises the error
exception.
@spec index_template_exists(name(), keyword()) :: exists_result()
Checks whether the index template name exists.
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Like index_template_exists/2, but returns the boolean directly
(404 → false) or raises the error exception.
Creates or updates the component template name
(Create or update component template API).
template is the request body, e.g. %{template: %{settings: %{...}}}. A
component template applies nothing by itself: name it in an index template's
composed_of to have it take effect.
Like put_component_template/3, but returns the body directly or raises the
error exception.
Creates or updates the index template name
(Create or update index template API).
template is the request body, e.g.
%{index_patterns: ["posts-*"], template: %{...}}.
%{index_patterns: ["logs-*"], template: %{settings: %{number_of_shards: 1}}}
|> Dowser.Opensearch.IndexTemplate.put_index_template("logs")
Like put_index_template/3, but returns the body directly or raises the
error exception.
Creates or updates the legacy index template name
(Create or update template API).
template is the request body, e.g.
%{index_patterns: ["posts-*"], settings: %{...}}.
This is the pre-composable /_template endpoint; prefer
put_index_template/3 for anything new.
Like put_template/3, but returns the body directly or raises the error
exception.
Simulates applying the matching index templates to the index name
(Simulate index API).
body is an optional template body to simulate alongside the existing ones;
pass %{} to send nothing. name is the index name to simulate the
creation of, not a template name.
Like simulate_index_template/3, but returns the body directly or raises
the error exception.
Simulates the resolved composition of an index template (Simulate template API).
body is a template body to simulate instead of a stored one; pass %{} to
send nothing.
Options
:name— a stored template to resolve, appended to the path; absent to resolve the body alone.
Like simulate_template/2, but returns the body directly or raises the
error exception.
@spec template_exists(name(), keyword()) :: exists_result()
Checks whether the legacy index template name exists.
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Like template_exists/2, but returns the boolean directly (404 → false)
or raises the error exception.