Dowser. Opensearch. Index
(Dowser.Opensearch v0.1.0)
View Source
The OpenSearch index APIs — the endpoints tagged Index in the
OpenSearch OpenAPI specification
(index lifecycle, resizing, rollover, maintenance and monitoring).
Built on Dowser.Client. Required OpenSearch attributes are positional
arguments; everything optional lives in opts.
OpenSearch splits what Elasticsearch tags as one indices group into several
tags, so the neighbouring APIs live in modules of their own:
Dowser.Opensearch.Mappings, Dowser.Opensearch.IndexSettings,
Dowser.Opensearch.Alias, Dowser.Opensearch.IndexTemplate,
Dowser.Opensearch.DataStream and Dowser.Opensearch.DanglingIndices. The
index-target helper they all share is Dowser.Opensearch.Target.
Shared conventions
- An index target may be
nil(all indices), a single index/alias/ data-stream name (string or atom), or a list of them (joined with,). Endpoints that accept an optional target take it as the:indexoption; endpoints that require one take it as the first argument. - Path parameters such as
target,metricorblockaccept the same shapes as an index target. - 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_exists/2returns{:ok, boolean()}or{:error, exception},index_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
Adds an index block to one or several indices (Add index block API).
Like add_block/3, but returns the body directly or raises the error
exception.
Clears the caches of one, several, or all indices (Clear cache API).
Like clear_cache/1, but returns the body directly or raises the error
exception.
Clones the index index into target
(Clone index API).
Like clone/4, but returns the body directly or raises the error exception.
Closes one or several indices (Close index API).
Like close/2, but returns the body directly or raises the error exception.
Creates the index index
(Create index API).
Like create_index/3, but returns the body directly or raises the error
exception.
Deletes one or several indices (Delete index API).
Like delete_index/2, but returns the body directly or raises the error
exception.
Flushes one, several, or all indices (Flush API).
Like flush/1, but returns the body directly or raises the error exception.
Force-merges the segments of one, several, or all indices (Force merge API).
Like forcemerge/1, but returns the body directly or raises the error
exception.
Returns the definition of one or several indices (Get index API).
Like get_index/2, but returns the body directly or raises the error
exception.
Checks whether one or several indices exist (Index exists API).
Like index_exists/2, but returns the boolean directly (404 → false) or
raises the error exception.
Opens one or several closed indices (Open index API).
Like open/2, but returns the body directly or raises the error exception.
Returns information about ongoing and completed shard recoveries (Recovery API).
Like recovery/1, but returns the body directly or raises the error
exception.
Refreshes one, several, or all indices (Refresh API).
Like refresh/1, but returns the body directly or raises the error
exception.
Resolves name — which may include wildcards — into the concrete indices,
aliases and data streams it matches
(Resolve index API).
Like resolve_index/2, but returns the body directly or raises the error
exception.
Rolls the rollover target target (an alias or data stream) over to a new
index
(Rollover API).
Like rollover/3, but returns the body directly or raises the error
exception.
Returns the shard segments of one, several, or all indices (Segments API).
Like segments/1, but returns the body directly or raises the error
exception.
Returns store information for the shards of one, several, or all indices (Shard stores API).
Like shard_stores/1, but returns the body directly or raises the error
exception.
Shrinks the index index into target, with fewer primary shards
(Shrink index API).
Like shrink/4, but returns the body directly or raises the error exception.
Splits the index index into target, with more primary shards
(Split index API).
Like split/4, but returns the body directly or raises the error exception.
Returns statistics for one, several, or all indices (Index stats API).
Like stats/1, but returns the body directly 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()}
@type t() :: Dowser.Opensearch.Target.t()
Functions
Adds an index block to one or several indices (Add index block API).
block is the block to add — "read_only", "read_only_allow_delete",
"read", "write" or "metadata".
Dowser.Opensearch.Index.add_block("posts", "write")OpenSearch has no endpoint for removing a block: clear one by setting the
corresponding index.blocks.* setting to nil through
Dowser.Opensearch.IndexSettings.put_settings/2.
Like add_block/3, but returns the body directly or raises the error
exception.
Clears the caches of one, several, or all indices (Clear cache API).
Options
:index— index target; absent for all indices.
Like clear_cache/1, but returns the body directly or raises the error
exception.
Clones the index index into target
(Clone index API).
body is the request body (e.g. settings, aliases); pass %{} to send
nothing. The source index must be blocked for writes first — see
add_block/3.
Like clone/4, but returns the body directly or raises the error exception.
Closes one or several indices (Close index API).
Like close/2, but returns the body directly or raises the error exception.
Creates the index index
(Create index API).
body is the request body (e.g. settings, mappings, aliases); pass
%{} to send nothing.
%{settings: %{number_of_shards: 3}, mappings: %{properties: %{title: %{type: "text"}}}}
|> Dowser.Opensearch.Index.create_index("posts")
Like create_index/3, but returns the body directly or raises the error
exception.
Deletes one or several indices (Delete index API).
Like delete_index/2, but returns the body directly or raises the error
exception.
Flushes one, several, or all indices (Flush API).
Options
:index— index target; absent for all indices.
Like flush/1, but returns the body directly or raises the error exception.
Force-merges the segments of one, several, or all indices (Force merge API).
Options
:index— index target; absent for all indices.
Like forcemerge/1, but returns the body directly or raises the error
exception.
Returns the definition of one or several indices (Get index API).
Like get_index/2, but returns the body directly or raises the error
exception.
@spec index_exists(t(), keyword()) :: exists_result()
Checks whether one or several indices exist (Index exists API).
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Like index_exists/2, but returns the boolean directly (404 → false) or
raises the error exception.
Opens one or several closed indices (Open index API).
Like open/2, but returns the body directly or raises the error exception.
Returns information about ongoing and completed shard recoveries (Recovery API).
Options
:index— index target; absent for all indices.
Like recovery/1, but returns the body directly or raises the error
exception.
Refreshes one, several, or all indices (Refresh API).
Options
:index— index target; absent for all indices.
Like refresh/1, but returns the body directly or raises the error
exception.
Resolves name — which may include wildcards — into the concrete indices,
aliases and data streams it matches
(Resolve index API).
Dowser.Opensearch.Index.resolve_index!("logs-*")
#=> %{"indices" => [...], "aliases" => [...], "data_streams" => [...]}
Like resolve_index/2, but returns the body directly or raises the error
exception.
Rolls the rollover target target (an alias or data stream) over to a new
index
(Rollover API).
body is the request body (e.g. conditions, settings, mappings,
aliases); pass %{} to send nothing.
Options
:new_index— explicit name for the new index; absent to let OpenSearch derive it.
Like rollover/3, but returns the body directly or raises the error
exception.
Returns the shard segments of one, several, or all indices (Segments API).
Options
:index— index target; absent for all indices.
Like segments/1, but returns the body directly or raises the error
exception.
Returns store information for the shards of one, several, or all indices (Shard stores API).
Options
:index— index target; absent for all indices.
Like shard_stores/1, but returns the body directly or raises the error
exception.
Shrinks the index index into target, with fewer primary shards
(Shrink index API).
body is the request body (e.g. settings, aliases); pass %{} to send
nothing.
Like shrink/4, but returns the body directly or raises the error exception.
Splits the index index into target, with more primary shards
(Split index API).
body is the request body (e.g. settings, aliases); pass %{} to send
nothing.
Like split/4, but returns the body directly or raises the error exception.
Returns statistics for one, several, or all indices (Index stats API).
Options
:index— index target; absent for all indices.:metric— restrict the result to one or several metrics.
Like stats/1, but returns the body directly or raises the error exception.