> This page is for Agent Handler.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Elasticsearch

> **Ready to connect**
>
> No custom OAuth app setup required. Sign in or provide your credentials to connect.

**Authentication:** API key and deployment endpoint. See [Magic Link](/merge-agent-handler/features/magic-link) for the runtime auth flow.

## Sample use cases

* Run an ES|QL query for error counts by service over the last hour.
* Show cluster health and the five largest indices by size.
* Create an index for support tickets and bulk load a batch of documents into it.

## Available Tools

#### add_alias

Add an alias to an index with PUT //\_alias/, optionally filtered or as the write index.

#### analyze_text

Analyze text with POST //\_analyze to see the tokens an analyzer produces, by named `analyzer` or by `field`.

#### bulk

Perform many index/create/update/delete actions in one request with POST //\_bulk.

#### cancel_task

Cancel a running, cancellable task via POST /\_tasks//\_cancel.

#### cat_aliases

List index aliases and the indices they point to via GET /\_cat/aliases.

#### cat_count

Show the total document count across the cluster via GET /\_cat/count.

#### cat_health

Show a one-line cluster health summary via GET /\_cat/health (status, node and shard counts).

#### cat_indices

List indices with health, status, document counts, and store size via GET /\_cat/indices.

#### cat_nodes

List cluster nodes with resource usage (heap, CPU, load, role) via GET /\_cat/nodes.

#### cat_shards

List shards with their index, state, document count, and node placement via GET /\_cat/shards.

#### close_index

Close an index with POST //\_close, blocking reads and writes until reopened.

#### close_point_in_time

Close a point-in-time context with DELETE /\_pit to free its resources.

#### cluster_health

Retrieve the full cluster health document via GET /\_cluster/health (status, node counts, shard counts).

#### cluster_stats

Retrieve aggregate cluster statistics via GET /\_cluster/stats (index, document, shard, and node totals).

#### count

Count documents matching an optional Lucene query with GET //\_count.

#### create_document

Create a new document at a given ID with POST //\_create/.

#### create_index

Create a new index with PUT /, optionally with `mappings`, `settings`, and `aliases`.

#### delete_alias

Remove an alias from an index with DELETE //\_alias/.

#### delete_by_query

Delete all documents matching a Query DSL query with POST //\_delete_by_query.

#### delete_document

Delete a document by ID with DELETE //\_doc/.

#### delete_index

Permanently delete an index and all its documents with DELETE /.

#### delete_index_template

Delete a composable index template by name with DELETE /\_index_template/.

#### delete_pipeline

Delete an ingest pipeline by ID via DELETE /\_ingest/pipeline/. Use `get_pipeline` to confirm it exists first.

#### esql_query

Run an ES|QL query with POST /\_query. ES|QL is Elasticsearch's piped query language, e.g. 'FROM products | STATS `count=COUNT(*)` BY category'.

#### explain_document

Explain whether and why a specific document matches a query with POST //\_explain/, returning the relevance score breakdown.

#### get_aliases

Retrieve the aliases attached to an index with GET //\_alias, keyed by index name.

#### get_cluster_info

Retrieve the cluster info document via GET / — the node name, cluster name, cluster UUID, and Elasticsearch version.

#### get_cluster_settings

Retrieve persistent and transient cluster settings via GET /\_cluster/settings.

#### get_document

Retrieve a document and its metadata by ID with GET //\_doc/.

#### get_document_source

Retrieve only the stored \_source body of a document by ID with GET //\_source/, without the surrounding metadata.

#### get_field_caps

Describe which indices a field exists in and its search/aggregation capabilities with POST //\_field_caps.

#### get_index

Retrieve an index's definition (aliases, mappings, settings) with GET /, keyed by index name.

#### get_index_stats

Retrieve statistics for an index (document counts, store size, operation counters) with GET //\_stats.

#### get_index_template

Retrieve a composable index template by name with GET /\_index_template/, including its index patterns, settings, and mappings.

#### get_mapping

Retrieve an index's field mappings with GET //\_mapping, keyed by index name.

#### get_pipeline

Retrieve an ingest pipeline definition by ID via GET /\_ingest/pipeline/.

#### get_settings

Retrieve an index's settings (shards, replicas, refresh interval, etc.) with GET //\_settings, keyed by index name.

#### get_task

Retrieve the status and result of a single task via GET /\_tasks/.

#### get_term_vectors

Retrieve term vectors and term statistics for a document's fields with POST //\_termvectors/.

#### index_document

Index (create or overwrite) a document at a given ID with PUT //\_doc/.

#### list_index_templates

List all composable index templates with GET /\_index_template.

#### list_pipelines

List all ingest pipelines via GET /\_ingest/pipeline.

#### list_tasks

List running tasks across the cluster via GET /\_tasks, grouped by node.

#### mget_documents

Fetch multiple documents in one request with POST //\_mget, by `ids` or per-document `docs` specs.

#### multi_search

Run several searches in one request with POST //\_msearch.

#### open_index

Open a closed index with POST //\_open so it accepts reads and writes again.

#### open_point_in_time

Open a point-in-time with POST //\_pit to run consistent paginated searches against a fixed view.

#### put_index_template

Create or replace a composable index template with PUT /\_index_template/, applying its settings/mappings to indices matching `index_patterns`.

#### put_pipeline

Create or replace an ingest pipeline via PUT /\_ingest/pipeline/ with an ordered list of `processors`.

#### refresh_index

Refresh an index with POST //\_refresh to make recent writes searchable immediately.

#### reindex

Copy documents from one index to another with POST /\_reindex, given `source` and `dest` specs.

#### search

Run a search with POST //\_search using the Query DSL, with size/from or search_after pagination, sort, aggregations, and \_source filtering.

#### terms_enum

Enumerate matching terms in a keyword field with POST //\_terms_enum, optionally filtered by a prefix `string`.

#### update_by_query

Update all documents matching a query with POST //\_update_by_query, applying an optional `script`.

#### update_cluster_settings

Update persistent and/or transient cluster settings via PUT /\_cluster/settings.

#### update_document

Partially update a document by ID with POST //\_update/, using a partial `doc` merge, a `script`, or an `upsert`.

#### update_mapping

Add fields to an index's mapping or change its dynamic mode with PUT //\_mapping.

#### update_settings

Update an index's dynamic settings with PUT //\_settings, e.g. number_of_replicas or refresh_interval.