> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/elasticsearch.md).

# Elasticsearch

Connect to Elasticsearch for search and analytics capabilities.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector     | Authentication |
| ------------- | -------------- |
| Elasticsearch | Credentials    |

#### Elasticsearch

Connect to Elasticsearch for powerful search and analytics capabilities. Supports full-text search, analytics, and distributed operations.

**Set up in Elasticsearch**

1. In Kibana, open **Stack Management → API keys** (or Security) and create an API key for programmatic access to your cluster.
2. Copy the API key value and note your Elasticsearch endpoint URL (or Cloud ID for Elastic Cloud deployments).

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Elasticsearch**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field     | Required                 | What to enter                                                                                                                                                                      |
| ----------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Endpoint          | Yes                      | The URL of your Elasticsearch cluster.                                                                                                                                             |
| API Key (Encoded) | Optional / as applicable | Elasticsearch API key (Encoded from web UI)Or use separate API Key ID and API Key Secret fields below. Leave empty if your cluster doesn't require authentication.                 |
| API Key ID        | Optional / as applicable | If you have an encoded API key from the web UI, use the 'API Key (Encoded)' field instead. Leave empty if using encoded API key or if your cluster doesn't require authentication. |
| API Key Secret    | Optional / as applicable | If you have an encoded API key from the web UI, use the 'API Key (Encoded)' field instead. Leave empty if using encoded API key or if your cluster doesn't require authentication. |

**Provider documentation:** [Setup reference](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys).

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Elasticsearch** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Index Document

Index a document in Elasticsearch

**Inputs**

| Field         | Type     | Required | Description                                                                                                     |
| ------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| Index         | string   | Yes      | The name of the Elasticsearch index to store the document in.                                                   |
| Document ID   | string   | No       | Optional unique identifier for the document. If not provided, Elasticsearch will auto-generate an ID.           |
| Document      | textarea | Yes      | The JSON document to index.                                                                                     |
| Refresh Index | boolean  | No       | Refresh the index immediately to make the document searchable (not recommended for high-volume production use). |

**Outputs**

| Field       | Type   | Description                                        |
| ----------- | ------ | -------------------------------------------------- |
| Document ID | string | The ID of the indexed document.                    |
| Index       | string | The index where the document was stored.           |
| Result      | string | The result of the operation (created or updated).  |
| Version     | number | The version number of the document.                |
| Message     | string | A message indicating the success of the operation. |

#### Get Document

Retrieve a document from Elasticsearch by ID

**Inputs**

| Field       | Type   | Required | Description                                                  |
| ----------- | ------ | -------- | ------------------------------------------------------------ |
| Index       | string | Yes      | The name of the Elasticsearch index containing the document. |
| Document ID | string | Yes      | The unique identifier of the document to retrieve.           |

**Outputs**

| Field       | Type    | Description                                       |
| ----------- | ------- | ------------------------------------------------- |
| Document ID | string  | The ID of the retrieved document.                 |
| Index       | string  | The index where the document is stored.           |
| Document    | object  | The document content.                             |
| Version     | number  | The version number of the document.               |
| Found       | boolean | Whether the document was found.                   |
| Message     | string  | A message indicating the result of the operation. |

#### Update Document

Update a document in Elasticsearch

**Inputs**

| Field           | Type     | Required | Description                                                                                                   |
| --------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------- |
| Index           | string   | Yes      | The name of the Elasticsearch index containing the document.                                                  |
| Document ID     | string   | Yes      | The unique identifier of the document to update.                                                              |
| Document Update | textarea | Yes      | The fields to update in the document as JSON (partial update).                                                |
| Refresh Index   | boolean  | No       | Refresh the index immediately to make the update searchable (not recommended for high-volume production use). |

**Outputs**

| Field       | Type   | Description                                        |
| ----------- | ------ | -------------------------------------------------- |
| Document ID | string | The ID of the updated document.                    |
| Index       | string | The index where the document is stored.            |
| Result      | string | The result of the operation (updated or noop).     |
| Version     | number | The new version number of the document.            |
| Message     | string | A message indicating the success of the operation. |

#### Delete Document

Delete a document from Elasticsearch

**Inputs**

| Field         | Type    | Required | Description                                                                                    |
| ------------- | ------- | -------- | ---------------------------------------------------------------------------------------------- |
| Index         | string  | Yes      | The name of the Elasticsearch index containing the document.                                   |
| Document ID   | string  | Yes      | The unique identifier of the document to delete.                                               |
| Refresh Index | boolean | No       | Refresh the index immediately after deletion (not recommended for high-volume production use). |

**Outputs**

| Field       | Type   | Description                                          |
| ----------- | ------ | ---------------------------------------------------- |
| Document ID | string | The ID of the deleted document.                      |
| Index       | string | The index where the document was stored.             |
| Result      | string | The result of the operation (deleted or not\_found). |
| Version     | number | The version number before deletion.                  |
| Message     | string | A message indicating the result of the operation.    |

#### Search Documents

Search documents in Elasticsearch using query DSL

**Inputs**

| Field        | Type     | Required | Description                                          |
| ------------ | -------- | -------- | ---------------------------------------------------- |
| Index        | string   | Yes      | The name of the Elasticsearch index to search in.    |
| Query        | textarea | Yes      | The Elasticsearch query DSL as JSON.                 |
| Size         | integer  | No       | Maximum number of documents to return (default: 10). |
| Start Offset | integer  | No       | Starting offset for pagination (default: 0).         |
| Sort         | textarea | No       | Optional sort criteria as JSON.                      |

**Outputs**

| Field           | Type   | Description                                      |
| --------------- | ------ | ------------------------------------------------ |
| Hits            | array  | The list of matching documents.                  |
| Total Hits      | number | The total number of matching documents.          |
| Max Score       | number | The highest relevance score.                     |
| Query Time (ms) | number | Time taken to execute the query in milliseconds. |
| Message         | string | A message summarizing the search results.        |

#### Bulk Operations

Perform multiple index, update, or delete operations in a single request

**Inputs**

| Field         | Type     | Required | Description                                                                                                           |
| ------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
| Index         | string   | No       | Optional default index for operations that don't specify one.                                                         |
| Operations    | textarea | Yes      | Newline-delimited JSON (NDJSON) bulk operations. Each operation is an action line followed by optional document data. |
| Refresh Index | boolean  | No       | Refresh the affected indices immediately after bulk operations (not recommended for high-volume production use).      |

**Outputs**

| Field                 | Type    | Description                                           |
| --------------------- | ------- | ----------------------------------------------------- |
| Results               | array   | The results of each operation in the bulk request.    |
| Time Taken (ms)       | number  | Time taken to execute all operations in milliseconds. |
| Has Errors            | boolean | Whether any operations failed.                        |
| Successful Operations | number  | Number of successful operations.                      |
| Failed Operations     | number  | Number of failed operations.                          |
| Message               | string  | A message summarizing the bulk operation results.     |

#### Ingest Attachment

Process and index file attachments in Elasticsearch

**Inputs**

| Field         | Type    | Required | Description                                                            |
| ------------- | ------- | -------- | ---------------------------------------------------------------------- |
| Index         | string  | Yes      | The name of the Elasticsearch index to store the document.             |
| File URL      | string  | Yes      | URL of the file to download and process.                               |
| Pipeline      | string  | Yes      | The ingest pipeline name that has the attachment processor configured. |
| Document ID   | string  | No       | Optional unique identifier for the document.                           |
| Refresh Index | boolean | No       | Refresh the index immediately to make the document searchable.         |

**Outputs**

| Field       | Type   | Description                                        |
| ----------- | ------ | -------------------------------------------------- |
| Document ID | string | The ID of the indexed document.                    |
| Index       | string | The index where the document was stored.           |
| Result      | string | The result of the operation (created or updated).  |
| Message     | string | A message indicating the success of the operation. |

#### Create Index

Create a new index in Elasticsearch with optional settings, mappings, and aliases

**Inputs**

| Field    | Type     | Required | Description                                                                 |
| -------- | -------- | -------- | --------------------------------------------------------------------------- |
| Index    | string   | Yes      | The name of the Elasticsearch index to create.                              |
| Settings | textarea | No       | Optional index settings as JSON (e.g., shards, replicas, default pipeline). |
| Mappings | textarea | No       | Optional field mappings as JSON to define the schema.                       |
| Aliases  | textarea | No       | Optional index aliases as JSON.                                             |

**Outputs**

| Field               | Type    | Description                                               |
| ------------------- | ------- | --------------------------------------------------------- |
| Index               | string  | The name of the created index.                            |
| Acknowledged        | boolean | Whether the operation was acknowledged by the cluster.    |
| Shards Acknowledged | boolean | Whether the required number of shard copies were started. |
| Message             | string  | A message indicating the success of the operation.        |

#### Update Index Settings

Update settings of an existing Elasticsearch index

**Inputs**

| Field    | Type     | Required | Description                                                                  |
| -------- | -------- | -------- | ---------------------------------------------------------------------------- |
| Index    | string   | Yes      | The name of the Elasticsearch index to update.                               |
| Settings | textarea | Yes      | Index settings to update as JSON (e.g., default pipeline, refresh interval). |

**Outputs**

| Field        | Type    | Description                                            |
| ------------ | ------- | ------------------------------------------------------ |
| Acknowledged | boolean | Whether the operation was acknowledged by the cluster. |
| Message      | string  | A message indicating the success of the operation.     |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/elasticsearch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
