# Elasticsearch (/integrations/elasticsearch)





{/* MANUAL-CONTENT-START:intro */}

Use [Elasticsearch](https://www.elastic.co/elasticsearch/) to search with Query DSL, manage documents and indexes, run bulk operations, and inspect cluster health. The block supports self-hosted and Elastic Cloud deployments.

{/* MANUAL-CONTENT-END */}

## Use the block [#usage-instructions]

Search with Query DSL, manage documents and indexes, run bulk operations, and inspect cluster health on a self-hosted or Elastic Cloud deployment.

## Actions [#actions]

### Elasticsearch Search [#elasticsearch-search]

Search documents in Elasticsearch using Query DSL. Returns matching documents with scores and metadata.

<ReferenceDetails>
  #### Input [#input]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name to search (e.g., "products", "logs-2024") |
  | `query` | string | No | Query DSL as JSON string. Example: \{"match":\{"title":"search term"}} or \{"bool":\{"must":\[...]}} |
  | `from` | number | No | Starting offset for pagination (e.g., 0, 10, 20). Default: 0 |
  | `size` | number | No | Number of results to return (e.g., 10, 25, 100). Default: 10 |
  | `sort` | string | No | Sort specification as JSON string. Example: \[\{"created\_at":"desc"}] or \[\{"\_score":"desc"},\{"name":"asc"}] |
  | `sourceIncludes` | string | No | Comma-separated list of fields to include in \_source |
  | `sourceExcludes` | string | No | Comma-separated list of fields to exclude from \_source |
  | `trackTotalHits` | boolean | No | Track accurate total hit count (default: true) |

  #### Output [#output]

  | Parameter | Type | Description |
  | - | - | - |
  | `took` | number | Time in milliseconds the search took |
  | `timed_out` | boolean | Whether the search timed out |
  | `hits` | object | Search results with total count and matching documents |
  | `aggregations` | json | Aggregation results if any |
</ReferenceDetails>

### Elasticsearch Index Document [#elasticsearch-index-document]

Index (create or update) a document in Elasticsearch.

<ReferenceDetails>
  #### Input [#input-1]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Target index name (e.g., "products", "logs-2024") |
  | `documentId` | string | No | Document ID (e.g., "abc123", "user\_456"). Auto-generated if not provided |
  | `document` | string | Yes | Document body as JSON string |
  | `refresh` | string | No | Refresh policy: true, false, or wait\_for |

  #### Output [#output-1]

  | Parameter | Type | Description |
  | - | - | - |
  | `_index` | string | Index where the document was stored |
  | `_id` | string | Document ID |
  | `_version` | number | Document version |
  | `result` | string | Operation result (created or updated) |
</ReferenceDetails>

### Elasticsearch Get Document [#elasticsearch-get-document]

Retrieve a document by ID from Elasticsearch.

<ReferenceDetails>
  #### Input [#input-2]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name (e.g., "products", "logs-2024") |
  | `documentId` | string | Yes | Document ID to retrieve (e.g., "abc123", "user\_456") |
  | `sourceIncludes` | string | No | Comma-separated list of fields to include |
  | `sourceExcludes` | string | No | Comma-separated list of fields to exclude |

  #### Output [#output-2]

  | Parameter | Type | Description |
  | - | - | - |
  | `_index` | string | Index name |
  | `_id` | string | Document ID |
  | `_version` | number | Document version |
  | `found` | boolean | Whether the document was found |
  | `_source` | json | Document content |
</ReferenceDetails>

### Elasticsearch Update Document [#elasticsearch-update-document]

Partially update a document in Elasticsearch using doc merge.

<ReferenceDetails>
  #### Input [#input-3]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name (e.g., "products", "logs-2024") |
  | `documentId` | string | Yes | Document ID to update (e.g., "abc123", "user\_456") |
  | `document` | string | Yes | Partial document to merge as JSON string |
  | `retryOnConflict` | number | No | Number of retries on version conflict |

  #### Output [#output-3]

  | Parameter | Type | Description |
  | - | - | - |
  | `_index` | string | Index name |
  | `_id` | string | Document ID |
  | `_version` | number | New document version |
  | `result` | string | Operation result (updated or noop) |
</ReferenceDetails>

### Elasticsearch Delete Document [#elasticsearch-delete-document]

Delete a document from Elasticsearch by ID.

<ReferenceDetails>
  #### Input [#input-4]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name (e.g., "products", "logs-2024") |
  | `documentId` | string | Yes | Document ID to delete (e.g., "abc123", "user\_456") |
  | `refresh` | string | No | Refresh policy: true, false, or wait\_for |

  #### Output [#output-4]

  | Parameter | Type | Description |
  | - | - | - |
  | `_index` | string | Index name |
  | `_id` | string | Document ID |
  | `_version` | number | Document version |
  | `result` | string | Operation result (deleted or not\_found) |
</ReferenceDetails>

### Elasticsearch Bulk Operations [#elasticsearch-bulk-operations]

Perform multiple index, create, delete, or update operations in a single request for high performance.

<ReferenceDetails>
  #### Input [#input-5]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | No | Default index for operations (e.g., "products", "logs-2024") |
  | `operations` | string | Yes | Bulk operations as NDJSON string. Index, create, and update use an action line followed by a document/update line; delete uses only an action line. Example: \{"index":\{"\_index":"products","\_id":"1"}}\n\{"name":"Widget"}\n |
  | `refresh` | string | No | Refresh policy: true, false, or wait\_for |

  #### Output [#output-5]

  | Parameter | Type | Description |
  | - | - | - |
  | `took` | number | Time in milliseconds the bulk operation took |
  | `errors` | boolean | Whether any operation had an error |
  | `items` | array | Results for each operation |
</ReferenceDetails>

### Elasticsearch Count [#elasticsearch-count]

Count documents matching a query in Elasticsearch.

<ReferenceDetails>
  #### Input [#input-6]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name to count documents in (e.g., "products", "logs-2024") |
  | `query` | string | No | Query DSL to filter documents (JSON string). Example: \{"match":\{"status":"active"}} |

  #### Output [#output-6]

  | Parameter | Type | Description |
  | - | - | - |
  | `count` | number | Number of documents matching the query |
  | `_shards` | object | Shard statistics |
</ReferenceDetails>

### Elasticsearch Create Index [#elasticsearch-create-index]

Create a new index with optional settings and mappings.

<ReferenceDetails>
  #### Input [#input-7]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name to create (e.g., "products", "logs-2024") |
  | `settings` | string | No | Index settings as JSON string |
  | `mappings` | string | No | Index mappings as JSON string |

  #### Output [#output-7]

  | Parameter | Type | Description |
  | - | - | - |
  | `acknowledged` | boolean | Whether the request was acknowledged |
  | `shards_acknowledged` | boolean | Whether the shards were acknowledged |
  | `index` | string | Created index name |
</ReferenceDetails>

### Elasticsearch Delete Index [#elasticsearch-delete-index]

Delete an index and all its documents. This operation is irreversible.

<ReferenceDetails>
  #### Input [#input-8]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name to delete (e.g., "products", "logs-2024") |

  #### Output [#output-8]

  | Parameter | Type | Description |
  | - | - | - |
  | `acknowledged` | boolean | Whether the deletion was acknowledged |
</ReferenceDetails>

### Elasticsearch Get Index [#elasticsearch-get-index]

Retrieve index information including settings, mappings, and aliases.

<ReferenceDetails>
  #### Input [#input-9]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `index` | string | Yes | Index name to retrieve info for (e.g., "products", "logs-2024") |

  #### Output [#output-9]

  | Parameter | Type | Description |
  | - | - | - |
  | `indices` | json | Matched indices keyed by index name, each with its aliases, mappings, and settings |
</ReferenceDetails>

### Elasticsearch Cluster Health [#elasticsearch-cluster-health]

Get the health status of the Elasticsearch cluster.

<ReferenceDetails>
  #### Input [#input-10]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `waitForStatus` | string | No | Wait until cluster reaches this status: green, yellow, or red |
  | `clusterTimeout` | string | No | How long Elasticsearch waits for the cluster to reach the requested status, as an Elasticsearch time value (e.g., 30s, 1m). Not named "timeout": that name is reserved by the tool transport as a client-side abort deadline in milliseconds. |

  #### Output [#output-10]

  | Parameter | Type | Description |
  | - | - | - |
  | `cluster_name` | string | Name of the cluster |
  | `status` | string | Cluster health status: green, yellow, or red |
  | `number_of_nodes` | number | Total number of nodes in the cluster |
  | `number_of_data_nodes` | number | Number of data nodes |
  | `active_shards` | number | Number of active shards |
  | `unassigned_shards` | number | Number of unassigned shards |
</ReferenceDetails>

### Elasticsearch Cluster Stats [#elasticsearch-cluster-stats]

Get Elasticsearch cluster health, node counts, and index statistics.

<ReferenceDetails>
  #### Input [#input-11]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |

  #### Output [#output-11]

  | Parameter | Type | Description |
  | - | - | - |
  | `cluster_name` | string | Name of the cluster |
  | `status` | string | Cluster health status |
  | `nodes` | object | Node statistics including count and versions |
  | `indices` | object | Index statistics including document count and store size |
</ReferenceDetails>

### Elasticsearch List Indices [#elasticsearch-list-indices]

List all indices in the Elasticsearch cluster with their health, status, and statistics.

<ReferenceDetails>
  #### Input [#input-12]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `deploymentType` | string | Yes | Deployment type: self\_hosted or cloud |
  | `host` | string | No | Elasticsearch host URL (for self-hosted) |
  | `cloudId` | string | No | Elastic Cloud ID (for cloud deployments) |
  | `authMethod` | string | Yes | Authentication method: api\_key or basic\_auth |
  | `apiKey` | string | No | Elasticsearch API key |
  | `username` | string | No | Username for basic auth |
  | `password` | string | No | Password for basic auth |
  | `includeSystemIndices` | boolean | No | Include Elasticsearch system indices (names starting with "."). Omitted by default. |

  #### Output [#output-12]

  | Parameter | Type | Description |
  | - | - | - |
  | `message` | string | Summary message about the indices |
  | `indices` | json | Array of index information objects (index, health, status, docsCount, storeSize, primaryShards, replicaShards). System indices are omitted unless includeSystemIndices is set. |
</ReferenceDetails>
