Dowser. Opensearch. Mappings
(Dowser.Opensearch v0.1.0)
View Source
The OpenSearch mapping APIs — the endpoints tagged Mappings 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 index-target helper they share
is Dowser.Opensearch.Target.
Note that a mapping fetched through get_mapping/1 is not what
Dowser.Opensearch.Codec casts against — that one comes from
Dowser.Opensearch.MappingCacher, which caches it per index and context.
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,).put_mapping/3requires one and takes it as an argument; the reads take it as the:indexoption. - Endpoints that accept a request body take it as their first argument,
required — pass
%{}to send nothing.
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
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 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.
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.
Types
@type body() :: term()
@type index() :: Dowser.Opensearch.Target.t()
@type name() :: Dowser.Opensearch.Target.name()
@type result() :: {:ok, body()} | {:error, Exception.t()}
Functions
Returns the mapping of one or several fields (Get field mapping API).
fields is one field name or several, and may include wildcards.
Options
:index— index target; absent for all indices.
Like get_field_mapping/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.
Updates the mapping of one or several indices (Put mapping API).
mapping is the mapping body, e.g. %{properties: %{title: %{type: "text"}}}.
%{properties: %{published_at: %{type: "date"}}}
|> Dowser.Opensearch.Mappings.put_mapping("posts")OpenSearch only lets a mapping grow: adding a field works, changing the type
of an existing one does not, and needs a reindex into a new index
(Dowser.Opensearch.Reindex.reindex/2).
Like put_mapping/3, but returns the body directly or raises the error
exception.