Dowser.Elasticsearch.Cat (Dowser.Elasticsearch v0.4.1)

View Source

The Elasticsearch compact and aligned text (CaT) APIs — every endpoint tagged cat in the Elasticsearch OpenAPI specification.

Built on Dowser.Client. The cat endpoints take no request body and no required attribute: each one's optional path parameter is an option, so every function has the same opts-only signature.

JSON, not text

The cat APIs are meant for humans at a terminal and answer in aligned text by default — but they honour the accept header Dowser.Client already sends, so the response comes back as JSON and is decoded like every other endpoint: a list of maps, one per row.

Dowser.Elasticsearch.Cat.indices!(index: "posts*")
#=> [%{"index" => "posts", "health" => "green", "docs.count" => "42", ...}]

Every value in those maps is a string — that is what the cat APIs emit, JSON or not. For the aligned text a terminal wants, ask for it explicitly: the format query parameter wins over the header, and resp_format: :raw keeps the body from being parsed as JSON.

Dowser.Elasticsearch.Cat.indices!(params: [format: "text", v: true], resp_format: :raw)

Shared options

Most cat endpoints accept the same query parameters, passed through :params:

  • v — add the column headers.
  • h — the columns to return, e.g. h: "index,docs.count".
  • s — the columns to sort on, e.g. s: "docs.count:desc".
  • bytes / time — the unit sizes and durations are expressed in ("kb", "gb", "s", "ms", …).
  • format — see above.

Use help/1 to ask an endpoint which columns it supports.

All remaining options are forwarded to Dowser.Client.request/4, e.g. :context, :params (query-string parameters), :format, :keys 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 ,).

Functions

Returns the aliases of one, several, or all indices (Cat aliases API).

Like aliases/1, but returns the body directly or raises the error exception.

Returns the disk space and shard count of each node (Cat allocation API).

Like allocation/1, but returns the body directly or raises the error exception.

Returns the circuit breaker statistics of each node (Cat circuit breaker API).

Like circuit_breaker/1, but returns the body directly or raises the error exception.

Like component_templates/1, but returns the body directly or raises the error exception.

Counts the documents of one, several, or all indices (Cat count API).

Like count/1, but returns the body directly or raises the error exception.

Returns the heap memory each field's fielddata uses, per node (Cat fielddata API).

Like fielddata/1, but returns the body directly or raises the error exception.

Returns the cluster health (Cat health API).

Like health/1, but returns the body directly or raises the error exception.

Lists the available cat APIs — GET /_cat (Cat help API).

Like help/1, but returns the endpoints directly or raises the error exception.

Returns high-level information about one, several, or all indices (Cat indices API).

Like indices/1, but returns the body directly or raises the error exception.

Returns the elected master node (Cat master API).

Like master/1, but returns the body directly or raises the error exception.

Returns the data frame analytics jobs (Cat data frame analytics API).

Like ml_data_frame_analytics/1, but returns the body directly or raises the error exception.

Returns the datafeeds of the anomaly detection jobs (Cat datafeeds API).

Like ml_datafeeds/1, but returns the body directly or raises the error exception.

Returns the anomaly detection jobs (Cat anomaly detectors API).

Like ml_jobs/1, but returns the body directly or raises the error exception.

Returns the trained models and their allocations (Cat trained model API).

Like ml_trained_models/1, but returns the body directly or raises the error exception.

Returns the custom node attributes (Cat nodeattrs API).

Like nodeattrs/1, but returns the body directly or raises the error exception.

Returns the nodes of the cluster (Cat nodes API).

Like nodes/1, but returns the body directly or raises the error exception.

Returns the cluster-level changes not yet executed (Cat pending tasks API).

Like pending_tasks/1, but returns the body directly or raises the error exception.

Returns the plugins installed on each node (Cat plugins API).

Like plugins/1, but returns the body directly or raises the error exception.

Returns the shard recoveries — ongoing and completed — of one, several, or all indices (Cat recovery API).

Like recovery/1, but returns the body directly or raises the error exception.

Returns the snapshot repositories of the cluster (Cat repositories API).

Like repositories/1, but returns the body directly or raises the error exception.

Returns the low-level Lucene segments of one, several, or all indices (Cat segments API).

Like segments/1, but returns the body directly or raises the error exception.

Returns the shards of one, several, or all indices, and the node each sits on (Cat shards API).

Like shards/1, but returns the body directly or raises the error exception.

Returns the snapshots held by one or several repositories (Cat snapshots API).

Like snapshots/1, but returns the body directly or raises the error exception.

Returns the tasks currently running on the nodes (Cat task management API).

Like tasks/1, but returns the body directly or raises the error exception.

Returns the index templates (Cat templates API).

Like templates/1, but returns the body directly or raises the error exception.

Returns the thread pools of each node (Cat thread pool API).

Like thread_pool/1, but returns the body directly or raises the error exception.

Returns the transforms of the cluster (Cat transforms API).

Like transforms/1, but returns the body directly or raises the error exception.

Types

body()

@type body() :: term()

index()

@type index() :: Dowser.Elasticsearch.Index.t()

name()

A path parameter: a single name, or several (joined with ,).

result()

@type result() :: {:ok, body()} | {:error, Exception.t()}

Functions

aliases(opts \\ [])

@spec aliases(keyword()) :: result()

Returns the aliases of one, several, or all indices (Cat aliases API).

Options

  • :name — restrict the result to one or several alias names.

aliases!(opts \\ [])

@spec aliases!(keyword()) :: body()

Like aliases/1, but returns the body directly or raises the error exception.

allocation(opts \\ [])

@spec allocation(keyword()) :: result()

Returns the disk space and shard count of each node (Cat allocation API).

Options

  • :node_id — restrict the result to one or several node ids.

allocation!(opts \\ [])

@spec allocation!(keyword()) :: body()

Like allocation/1, but returns the body directly or raises the error exception.

circuit_breaker(opts \\ [])

@spec circuit_breaker(keyword()) :: result()

Returns the circuit breaker statistics of each node (Cat circuit breaker API).

Options

  • :circuit_breaker_patterns — restrict the result to one or several circuit breaker names or patterns.

circuit_breaker!(opts \\ [])

@spec circuit_breaker!(keyword()) :: body()

Like circuit_breaker/1, but returns the body directly or raises the error exception.

component_templates(opts \\ [])

@spec component_templates(keyword()) :: result()

Returns the component templates (Cat component templates API).

Options

  • :name — restrict the result to one or several component template names or patterns.

component_templates!(opts \\ [])

@spec component_templates!(keyword()) :: body()

Like component_templates/1, but returns the body directly or raises the error exception.

count(opts \\ [])

@spec count(keyword()) :: result()

Counts the documents of one, several, or all indices (Cat count API).

Options

  • :index — index target; absent for all indices.

count!(opts \\ [])

@spec count!(keyword()) :: body()

Like count/1, but returns the body directly or raises the error exception.

fielddata(opts \\ [])

@spec fielddata(keyword()) :: result()

Returns the heap memory each field's fielddata uses, per node (Cat fielddata API).

Options

  • :fields — restrict the result to one or several field names.

fielddata!(opts \\ [])

@spec fielddata!(keyword()) :: body()

Like fielddata/1, but returns the body directly or raises the error exception.

health(opts \\ [])

@spec health(keyword()) :: result()

Returns the cluster health (Cat health API).

health!(opts \\ [])

@spec health!(keyword()) :: body()

Like health/1, but returns the body directly or raises the error exception.

help(opts \\ [])

@spec help(keyword()) :: {:ok, [String.t()]} | {:error, Exception.t()}

Lists the available cat APIs — GET /_cat (Cat help API).

This one endpoint answers in plain text whatever the accept header says — a banner line, then one endpoint per line — so the response format defaults to :raw and the body is parsed here into the list of endpoints:

Dowser.Elasticsearch.Cat.help!()
#=> ["/_cat/allocation", "/_cat/shards", "/_cat/shards/{index}", ...]

Pass resp_format: :json (or :ndjson) to opt out of both the :raw default and the parsing, and get whatever Dowser.Client decodes instead.

help!(opts \\ [])

@spec help!(keyword()) :: [String.t()]

Like help/1, but returns the endpoints directly or raises the error exception.

indices(opts \\ [])

@spec indices(keyword()) :: result()

Returns high-level information about one, several, or all indices (Cat indices API).

Options

  • :index — index target; absent for all indices.

indices!(opts \\ [])

@spec indices!(keyword()) :: body()

Like indices/1, but returns the body directly or raises the error exception.

master(opts \\ [])

@spec master(keyword()) :: result()

Returns the elected master node (Cat master API).

master!(opts \\ [])

@spec master!(keyword()) :: body()

Like master/1, but returns the body directly or raises the error exception.

ml_data_frame_analytics(opts \\ [])

@spec ml_data_frame_analytics(keyword()) :: result()

Returns the data frame analytics jobs (Cat data frame analytics API).

Options

  • :id — restrict the result to one data frame analytics job id.

ml_data_frame_analytics!(opts \\ [])

@spec ml_data_frame_analytics!(keyword()) :: body()

Like ml_data_frame_analytics/1, but returns the body directly or raises the error exception.

ml_datafeeds(opts \\ [])

@spec ml_datafeeds(keyword()) :: result()

Returns the datafeeds of the anomaly detection jobs (Cat datafeeds API).

Options

  • :datafeed_id — restrict the result to one datafeed id.

ml_datafeeds!(opts \\ [])

@spec ml_datafeeds!(keyword()) :: body()

Like ml_datafeeds/1, but returns the body directly or raises the error exception.

ml_jobs(opts \\ [])

@spec ml_jobs(keyword()) :: result()

Returns the anomaly detection jobs (Cat anomaly detectors API).

Options

  • :job_id — restrict the result to one job id.

ml_jobs!(opts \\ [])

@spec ml_jobs!(keyword()) :: body()

Like ml_jobs/1, but returns the body directly or raises the error exception.

ml_trained_models(opts \\ [])

@spec ml_trained_models(keyword()) :: result()

Returns the trained models and their allocations (Cat trained model API).

Options

  • :model_id — restrict the result to one trained model id.

ml_trained_models!(opts \\ [])

@spec ml_trained_models!(keyword()) :: body()

Like ml_trained_models/1, but returns the body directly or raises the error exception.

nodeattrs(opts \\ [])

@spec nodeattrs(keyword()) :: result()

Returns the custom node attributes (Cat nodeattrs API).

nodeattrs!(opts \\ [])

@spec nodeattrs!(keyword()) :: body()

Like nodeattrs/1, but returns the body directly or raises the error exception.

nodes(opts \\ [])

@spec nodes(keyword()) :: result()

Returns the nodes of the cluster (Cat nodes API).

nodes!(opts \\ [])

@spec nodes!(keyword()) :: body()

Like nodes/1, but returns the body directly or raises the error exception.

pending_tasks(opts \\ [])

@spec pending_tasks(keyword()) :: result()

Returns the cluster-level changes not yet executed (Cat pending tasks API).

pending_tasks!(opts \\ [])

@spec pending_tasks!(keyword()) :: body()

Like pending_tasks/1, but returns the body directly or raises the error exception.

plugins(opts \\ [])

@spec plugins(keyword()) :: result()

Returns the plugins installed on each node (Cat plugins API).

plugins!(opts \\ [])

@spec plugins!(keyword()) :: body()

Like plugins/1, but returns the body directly or raises the error exception.

recovery(opts \\ [])

@spec recovery(keyword()) :: result()

Returns the shard recoveries — ongoing and completed — of one, several, or all indices (Cat recovery API).

Options

  • :index — index target; absent for all indices.

recovery!(opts \\ [])

@spec recovery!(keyword()) :: body()

Like recovery/1, but returns the body directly or raises the error exception.

repositories(opts \\ [])

@spec repositories(keyword()) :: result()

Returns the snapshot repositories of the cluster (Cat repositories API).

repositories!(opts \\ [])

@spec repositories!(keyword()) :: body()

Like repositories/1, but returns the body directly or raises the error exception.

segments(opts \\ [])

@spec segments(keyword()) :: result()

Returns the low-level Lucene segments of one, several, or all indices (Cat segments API).

Options

  • :index — index target; absent for all indices.

segments!(opts \\ [])

@spec segments!(keyword()) :: body()

Like segments/1, but returns the body directly or raises the error exception.

shards(opts \\ [])

@spec shards(keyword()) :: result()

Returns the shards of one, several, or all indices, and the node each sits on (Cat shards API).

Options

  • :index — index target; absent for all indices.

shards!(opts \\ [])

@spec shards!(keyword()) :: body()

Like shards/1, but returns the body directly or raises the error exception.

snapshots(opts \\ [])

@spec snapshots(keyword()) :: result()

Returns the snapshots held by one or several repositories (Cat snapshots API).

Options

  • :repository — restrict the result to one or several repository names; absent for all repositories.

snapshots!(opts \\ [])

@spec snapshots!(keyword()) :: body()

Like snapshots/1, but returns the body directly or raises the error exception.

tasks(opts \\ [])

@spec tasks(keyword()) :: result()

Returns the tasks currently running on the nodes (Cat task management API).

tasks!(opts \\ [])

@spec tasks!(keyword()) :: body()

Like tasks/1, but returns the body directly or raises the error exception.

templates(opts \\ [])

@spec templates(keyword()) :: result()

Returns the index templates (Cat templates API).

Options

  • :name — restrict the result to one or several template names or patterns.

templates!(opts \\ [])

@spec templates!(keyword()) :: body()

Like templates/1, but returns the body directly or raises the error exception.

thread_pool(opts \\ [])

@spec thread_pool(keyword()) :: result()

Returns the thread pools of each node (Cat thread pool API).

Options

  • :thread_pool_patterns — restrict the result to one or several thread pool names or patterns.

thread_pool!(opts \\ [])

@spec thread_pool!(keyword()) :: body()

Like thread_pool/1, but returns the body directly or raises the error exception.

transforms(opts \\ [])

@spec transforms(keyword()) :: result()

Returns the transforms of the cluster (Cat transforms API).

Options

  • :transform_id — restrict the result to one transform id.

transforms!(opts \\ [])

@spec transforms!(keyword()) :: body()

Like transforms/1, but returns the body directly or raises the error exception.