Dowser. Elasticsearch. Index
(Dowser.Elasticsearch v0.1.0)
View Source
The Elasticsearch indices APIs — every endpoint tagged indices in the
Elasticsearch OpenAPI specification
(index management, mappings, settings, aliases, templates, dangling indices,
…) — plus segment/1, the index-target helper used by all API modules.
Built on Dowser.Client. Required Elasticsearch attributes are positional
arguments; everything optional lives in opts.
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
name,fieldsormetricaccept 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.
:config, :params (query-string parameters), :format, :http_adapter,
:json_adapter and :http_opts (including :headers).
On a 2xx response every function returns {:ok, body} with the decoded
response body. A non-2xx response returns
{:error, %Dowser.Elasticsearch.Error{}}; a transport, encoding or decoding
failure returns {:error, exception} from Dowser.Client. Each function has
a bang variant that returns the body directly or raises the error exception.
Summary
Types
A path parameter: a single name, or several (joined with ,).
No index (all), a single index, or several indices.
Functions
Adds the block block (e.g. "write", "read_only") to one or several
indices
(Add block API).
Like add_block/3, but returns the body directly or raises the error
exception.
Checks whether one or several aliases exist (Alias exists API).
Like alias_exists/2, but returns the boolean directly (404 → false) or
raises the error exception.
Runs text through an analyzer (Analyze API).
Like analyze/2, 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.
Checks whether the component template name exists
(Component template exists API).
Like component_template_exists/2, but returns the boolean directly
(404 → false) 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 the alias name from one or several indices
(Delete alias API).
Like delete_alias/3, but returns the body directly or raises the error
exception.
Deletes one or several component templates (Delete component template API).
Like delete_component_template/2, but returns the body directly or raises
the error exception.
Deletes the dangling index index_uuid
(Delete dangling index API).
Like delete_dangling_index/2, but returns the body directly or raises the
error exception.
Removes the lifecycle from one or several data streams (Delete data lifecycle API).
Like delete_data_lifecycle/2, 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.
Deletes one or several index templates (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.
Analyzes the disk usage of each field of one or several indices (Disk usage API).
Like disk_usage/2, but returns the body directly or raises the error
exception.
Returns field-usage statistics for one or several indices (Field usage stats API).
Like field_usage_stats/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 one, several, or all aliases (Get alias API).
Like get_alias/1, but returns the body directly or raises the error
exception.
Returns one or several component templates (Get component template API).
Like get_component_template/2, but returns the body directly or raises the
error exception.
Returns the mapping of one or several fields (Get field mapping API).
Like get_field_mapping/2, but returns the body directly or raises the
error exception.
Returns information about one or several indices (Get index API).
Like get_index/2, but returns the body directly or raises the error
exception.
Returns one or several index templates (Get index template API).
Like get_index_template/2, but returns the body directly or raises the
error exception.
Returns the mapping of one, several, or all indices (Get mapping API).
Like get_mapping/1, but returns the body directly or raises the error
exception.
Returns the settings of one, several, or all indices (Get index settings API).
Like get_settings/1, but returns the body directly or raises the error
exception.
Returns one or several legacy index templates (Get template API).
Like get_template/2, but returns the body directly or raises the error
exception.
Imports the dangling index index_uuid
(Import dangling index API).
Like import_dangling_index/2, but returns the body directly or raises the
error exception.
Checks whether one or several indices exist (Exists API).
Like index_exists/2, but returns the boolean directly (404 → false) or
raises the error exception.
Checks whether the index template name exists
(Index template exists API).
Like index_template_exists/2, but returns the boolean directly
(404 → false) or raises the error exception.
Lists the dangling indices of the cluster (List dangling indices API).
Like list_dangling_indices/1, but returns the body directly 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.
Creates or updates the alias name on one or several indices
(Create or update alias API).
Like put_alias/4, but returns the body directly 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.
Updates the mapping of one or several indices (Put mapping API).
Like put_mapping/3, but returns the body directly or raises the error
exception.
Updates the settings of one, several, or all indices (Update index settings API).
Like put_settings/2, 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.
Returns shard-recovery information for one, several, or all indices (Index 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.
Reloads the search analyzers of one or several indices (Reload search analyzers API).
Like reload_search_analyzers/2, but returns the body directly or raises
the error exception.
Removes the block block from one or several indices
(Remove block API).
Like remove_block/3, but returns the body directly or raises the error
exception.
Resolves cluster expressions (for cross-cluster search) and reports each remote's availability (Resolve cluster API).
Like resolve_cluster/2, but returns the body directly or raises the error
exception.
Resolves names (with wildcards) to indices, aliases and data streams (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.
Encodes an index target into a comma-separated, URL-encoded path segment.
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 shard-store information for 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.
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 the index template name
(Simulate template API).
Like simulate_template/3, 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.
Checks whether one or several legacy index templates exist (Template exists API).
Like template_exists/2, but returns the boolean directly (404 → false)
or raises the error exception.
Applies several alias actions atomically (Update aliases API).
Like update_aliases/2, but returns the body directly or raises the error
exception.
Validates a query without running it (Validate query API).
Like validate_query/2, but returns the body directly or raises the error
exception.
Types
@type body() :: term()
@type exists_result() :: {:ok, boolean()} | {:error, Exception.t()}
A path parameter: a single name, or several (joined with ,).
@type result() :: {:ok, body()} | {:error, Exception.t()}
No index (all), a single index, or several indices.
Functions
Adds the block block (e.g. "write", "read_only") to one or several
indices
(Add block API).
Like add_block/3, but returns the body directly or raises the error
exception.
@spec alias_exists( name(), keyword() ) :: exists_result()
Checks whether one or several aliases exist (Alias exists API).
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Options
:index— index target; absent for all indices.
Like alias_exists/2, but returns the boolean directly (404 → false) or
raises the error exception.
Runs text through an analyzer (Analyze API).
body is the request body, e.g. %{analyzer: "standard", text: "hello"}.
Options
:index— index whose analyzers to use; absent for the cluster default.
Like analyze/2, 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.
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.
@spec component_template_exists( name(), keyword() ) :: exists_result()
Checks whether the component template name exists
(Component template exists API).
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.
Creates the index index
(Create index API).
body is the request body (e.g. settings, mappings, aliases); pass
%{} to send nothing.
Like create_index/3, but returns the body directly or raises the error
exception.
Deletes the alias name from one or several indices
(Delete alias API).
Like delete_alias/3, but returns the body directly or raises the error
exception.
Deletes one or several component templates (Delete component template API).
Like delete_component_template/2, but returns the body directly or raises
the error exception.
Deletes the dangling index index_uuid
(Delete dangling index API).
Requires params: [accept_data_loss: true].
Like delete_dangling_index/2, but returns the body directly or raises the
error exception.
Removes the lifecycle from one or several data streams (Delete data lifecycle API).
Like delete_data_lifecycle/2, 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.
Deletes one or several index templates (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.
Analyzes the disk usage of each field of one or several indices (Disk usage API).
Like disk_usage/2, but returns the body directly or raises the error
exception.
Returns field-usage statistics for one or several indices (Field usage stats API).
Like field_usage_stats/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 one, several, or all aliases (Get alias API).
Options
:index— index target; absent for all indices.:name— restrict the result to one or several alias names.
Like get_alias/1, but returns the body directly or raises the error
exception.
Returns one or several component templates (Get component template API).
Like get_component_template/2, but returns the body directly or raises the
error exception.
Returns the mapping of one or several fields (Get field mapping API).
Options
:index— index target; absent for all indices.
Like get_field_mapping/2, but returns the body directly or raises the
error exception.
Returns information about one or several indices (Get index API).
Like get_index/2, but returns the body directly or raises the error
exception.
Returns one or several index templates (Get index template API).
Like get_index_template/2, but returns the body directly or raises the
error exception.
Returns the mapping of one, several, or all indices (Get mapping API).
Options
:index— index target; absent for all indices.
Like get_mapping/1, but returns the body directly or raises the error
exception.
Returns the settings of one, several, or all indices (Get index settings API).
Options
:index— index target; absent for all indices.:name— restrict the result to one or several setting names.
Like get_settings/1, but returns the body directly or raises the error
exception.
Returns one or several legacy index templates (Get template API).
Like get_template/2, but returns the body directly or raises the error
exception.
Imports the dangling index index_uuid
(Import dangling index API).
Requires params: [accept_data_loss: true].
Like import_dangling_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 (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.
@spec index_template_exists( name(), keyword() ) :: exists_result()
Checks whether the index template name exists
(Index template exists API).
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.
Lists the dangling indices of the cluster (List dangling indices API).
Like list_dangling_indices/1, but returns the body directly 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.
Creates or updates the alias name on one or several indices
(Create or update alias API).
body is the request body (e.g. filter, routing); pass %{} to send
nothing.
Like put_alias/4, but returns the body directly 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: %{...}}}.
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: %{...}}.
Like put_index_template/3, but returns the body directly or raises the
error exception.
Updates the mapping of one or several indices (Put mapping API).
mapping is the mapping body, e.g. %{properties: %{title: %{type: "text"}}}.
Like put_mapping/3, but returns the body directly or raises the error
exception.
Updates the settings of one, several, or all indices (Update index settings API).
settings is the settings body, e.g. %{index: %{number_of_replicas: 2}}.
Options
:index— index target; absent for all indices.
Like put_settings/2, 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.
Returns shard-recovery information for one, several, or all indices (Index 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.
Reloads the search analyzers of one or several indices (Reload search analyzers API).
Like reload_search_analyzers/2, but returns the body directly or raises
the error exception.
Removes the block block from one or several indices
(Remove block API).
Like remove_block/3, but returns the body directly or raises the error
exception.
Resolves cluster expressions (for cross-cluster search) and reports each remote's availability (Resolve cluster API).
Like resolve_cluster/2, but returns the body directly or raises the error
exception.
Resolves names (with wildcards) to indices, aliases and data streams (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).
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 Elasticsearch derive it.
Like rollover/3, but returns the body directly or raises the error
exception.
Encodes an index target into a comma-separated, URL-encoded path segment.
Returns nil when the target is empty (nil, "" or []), so callers can
choose between /_search and /posts/_search.
Examples
iex> Dowser.Elasticsearch.Index.segment(nil)
nil
iex> Dowser.Elasticsearch.Index.segment("posts")
"posts"
iex> Dowser.Elasticsearch.Index.segment(["posts", "my comments"])
"posts,my%20comments"
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 shard-store information for 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.
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.
Like simulate_index_template/3, but returns the body directly or raises
the error exception.
Simulates the resolved composition of the index template name
(Simulate template API).
body is an optional template body to simulate instead of a stored one;
pass %{} to send nothing.
Like simulate_template/3, 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.
@spec template_exists( name(), keyword() ) :: exists_result()
Checks whether one or several legacy index templates exist (Template exists API).
Returns {:ok, true}, {:ok, false} or {:error, exception}.
Like template_exists/2, but returns the boolean directly (404 → false)
or raises the error exception.
Applies several alias actions atomically (Update aliases API).
actions is the list of actions, sent as %{actions: actions}, e.g.
[%{add: %{index: "posts", alias: "blog"}}].
Like update_aliases/2, but returns the body directly or raises the error
exception.
Validates a query without running it (Validate query API).
query is the validate body (query DSL map).
Options
:index— index target; absent for all indices.
Like validate_query/2, but returns the body directly or raises the error
exception.