> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hightouch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Elasticsearch

> Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured.

## Supported syncing

| Sync Type | Description | Supported Sync Modes | API Reference |
| - | - | - | - |
| **Index documents** | Sync data from any source to an Elasticsearch index | Upsert, Update | [Index API](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/docs-index_.html) |

## Connect to Elasticsearch

Go to the [**Destinations** overview page](https://app.hightouch.com/destinations?from=docs) and click the **Add destination** button. Select **Elasticsearch** and click **Continue**. You can then authenticate Hightouch to Elasticsearch either with an Elasticsearch **Cloud ID** and **API key** or via optional [basic authentication](https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html).

### Authenticate with an Elasticsearch Cloud ID and API key

You can find your [Cloud ID](https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html) in your Elasticsearch deployment. To generate an API key, follow these steps in the [Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html).

### Authenticate with basic authentication

Enter the following fields into Hightouch:

* **Protocol**: Select the protocol used for connecting to Elasticsearch. This is either `HTTP` or `HTTPS`.
* **Host**: The hostname or IP address of your Elasticsearch server.
* **Port**: The port number of your Elasticsearch server's HTTP API. The default is 9200, but yours may be different.
* **Username**: This can be your personal Elasticsearch login or a dedicated user for Hightouch.
* **Password**: The password for the user specified above.

## Sync configuration

Once you've set up your Elasticsearch destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull data from, you can set up your sync configuration to begin syncing data. Go to the [**Syncs** overview page](https://app.hightouch.com/syncs?from=docs) and click the **Add sync** button to begin. Then, select the relevant model and the Elasticsearch destination you want to sync to.

### Syncing to an index

An Elasticsearch [index](https://www.elastic.co/blog/what-is-an-elasticsearch-index) is the place where the data used by a search engine is stored. You can use Hightouch to update individual [documents](https://www.elastic.co/guide/en/elasticsearch/reference/current/documents-indices.html#:~:text=Elasticsearch%20is%20a%20distributed%20document,been%20serialized%20as%20JSON%20documents.) in an index.

#### Record matching

To match rows from your model to documents in Elasticsearch, you need to select a model column and corresponding Elasticsearch field. You can match on any Elasticsearch field.

#### Field mapping

You can sync data to both existing fields and fields that don't yet exist in Elasticsearch. If you send data to a field that doesn't exist yet, Hightouch adds the field and automatically detects its type.

#### Delete behavior

The [delete behavior](https://docs.hightouch.com/syncs/overview.md#delete-behavior) you select dictates what to do when a row no longer appears in your model's query results. You have the following options:

| Behavior | Description |
| - | - |
| **Do nothing** | Keep the document in Elasticsearch |
| **Clear** | Keep the document in Elasticsearch, but set mapped fields to empty |
| **Delete** | Remove the document from Elasticsearch |

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

> [!NOTE]
>
> For Hightouch platform error codes related to Elasticsearch, see [Error codes: Elasticsearch](https://docs.hightouch.com/developer-tools/error-codes.md#other-destinations).

**Connect to Elasticsearch on AWS**

To connect to an AWS hosted Elasticsearch, connect to Elastic Cloud where the instance has a Cloud ID, then generate an API key. If you can't connect via this method, use the basic authentication method to connect with username and password.

> [!WARNING]
>
> There may be compatibility issues across different versions of Elasticsearch. If you receive an error when you test the connection, please [reach out to customer support](#pylon-chat) for support for your specific version.

If you are running Elasticsearch via Amazon OpenSearch Service, connect directly via the [OpenSearch destination](https://docs.hightouch.com/destinations/opensearch.md)
