Dowser. Opensearch. Reindex
(Dowser.Opensearch v0.1.0)
View Source
The OpenSearch reindex and by-query APIs — the endpoints tagged Reindex in
the OpenSearch OpenAPI specification.
Built on Dowser.Client. Required OpenSearch attributes are positional
arguments; everything optional lives in opts.
OpenSearch groups _reindex, _delete_by_query and _update_by_query under
one tag, along with the _rethrottle endpoint each of them has, so they all
live here — where Elasticsearch tags them as document APIs.
Shared conventions
- Endpoints that accept a request body take it as their first argument,
required — pass
%{}to send nothing. The argument is namedquerywhen the body is an OpenSearch query DSL document andbodyotherwise. - The by-query endpoints require an index target, so they take it as an argument rather than an option.
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).
None of these endpoints is marked retryable: each one writes, and a
_reindex or _update_by_query that timed out may well have applied part of
its work, so re-sending it would redo that part. Pass retry: [idempotent: true] to override that for a call you know is safe to repeat.
Running long operations in the background
Every endpoint here can take longer than a request should, so OpenSearch
accepts params: [wait_for_completion: false] on all of them: the response
is then a task id, which _tasks reports on and the *_rethrottle
functions below can slow down or speed up.
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
Deletes every document matching a query (Delete by query API).
Like delete_by_query/3, but returns the body directly or raises the error
exception.
Changes the throttling of the running delete-by-query task task_id
(Delete by query rethrottle API).
Like delete_by_query_rethrottle/3, but returns the body directly or raises
the error exception.
Copies documents from one index to another (Reindex API).
Like reindex/2, but returns the body directly or raises the error
exception.
Changes the throttling of the running reindex task task_id
(Reindex rethrottle API).
Like reindex_rethrottle/3, but returns the body directly or raises the
error exception.
Updates every document matching a query (Update by query API).
Like update_by_query/3, but returns the body directly or raises the error
exception.
Changes the throttling of the running update-by-query task task_id
(Update by query rethrottle API).
Like update_by_query_rethrottle/3, but returns the body directly or raises
the error exception.
Types
@type body() :: term()
@type id() :: String.t()
@type index() :: Dowser.Opensearch.Target.t()
@type result() :: {:ok, body()} | {:error, Exception.t()}
Functions
Deletes every document matching a query (Delete by query API).
query is the delete body (query DSL map).
Like delete_by_query/3, but returns the body directly or raises the error
exception.
Changes the throttling of the running delete-by-query task task_id
(Delete by query rethrottle API).
requests_per_second is sent as the required query-string parameter.
Like delete_by_query_rethrottle/3, but returns the body directly or raises
the error exception.
Copies documents from one index to another (Reindex API).
body is the request body, e.g.
%{source: %{index: "old"}, dest: %{index: "new"}}.
%{source: %{index: "posts-v1"}, dest: %{index: "posts-v2"}}
|> Dowser.Opensearch.Reindex.reindex(params: [wait_for_completion: false])
Like reindex/2, but returns the body directly or raises the error
exception.
Changes the throttling of the running reindex task task_id
(Reindex rethrottle API).
requests_per_second is sent as the required query-string parameter; pass
-1 to remove the throttle entirely.
Like reindex_rethrottle/3, but returns the body directly or raises the
error exception.
Updates every document matching a query (Update by query API).
body is the request body (e.g. query, script); pass %{} to update
everything.
Like update_by_query/3, but returns the body directly or raises the error
exception.
Changes the throttling of the running update-by-query task task_id
(Update by query rethrottle API).
requests_per_second is sent as the required query-string parameter.
Like update_by_query_rethrottle/3, but returns the body directly or raises
the error exception.