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

# Elasticsearch

> The driver for Elasticsearch is community-supported and is not maintained by Cube or the database vendor.

<Warning>
  The driver for Elasticsearch is community-supported and is not maintained by Cube or the database vendor.
</Warning>

<Warning>
  Elasticsearch driver is deprecated and will be removed in a future release.
</Warning>

## Prerequisites

To connect to an [Elasticsearch][elasticsearch] database, use [`CUBEJS_DB_URL`](/reference/configuration/environment-variables#cubejs_db_url)
with the username and password embedded in the URL, if required.

<Warning>
  If you're not using [Elastic Cloud][elastic-cloud], you **must** specify
  [`CUBEJS_DB_ELASTIC_QUERY_FORMAT`](/reference/configuration/environment-variables#cubejs_db_elastic_query_format).
</Warning>

## Setup

### Manual

For a self-hosted Elasticsearch instance, add the following to a `.env` file in
your Cube project:

```dotenv theme={"dark"}
CUBEJS_DB_TYPE=elasticsearch
CUBEJS_DB_URL=https://my.elasticsearch.host:9200
CUBEJS_DB_ELASTIC_QUERY_FORMAT=json
```

For an Elasticsearch instanced hosted by [Elastic.co][elastic-co], add the
following to a `.env` file in your Cube project:

```dotenv theme={"dark"}
CUBEJS_DB_TYPE=elasticsearch
CUBEJS_DB_URL=https://my.elasticsearch.host:9200
CUBEJS_DB_ELASTIC_APIKEY_ID=VuaCfGcBCdbkQm-e5aOx
CUBEJS_DB_ELASTIC_APIKEY_KEY=ui2lp2axTNmsyakw9tvNnw
```

## Environment Variables

| Environment Variable                                                                                              | Description                                                                                                                                                                              | Possible Values                        | Required |
| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | :------: |
| [`CUBEJS_DB_URL`](/reference/configuration/environment-variables#cubejs_db_url)                                   | The URL for a database                                                                                                                                                                   | A valid database URL for Elasticsearch |     ✅    |
| [`CUBEJS_DB_ELASTIC_QUERY_FORMAT`](/reference/configuration/environment-variables#cubejs_db_elastic_query_format) | By default, queries return data in JDBC format, but you can also return data in standard Elasticsearch JDBC, JSON, CSV, YAML or raw formats (only JSON and JDBC are currently supported) | `json`, `jdbc`                         |     ❌    |
| [`CUBEJS_DB_ELASTIC_OPENDISTRO`](/reference/configuration/environment-variables#cubejs_db_elastic_opendistro)     | If `true`, then use the Open Distro for Elasticsearch                                                                                                                                    | `true`, `false`                        |     ❌    |
| [`CUBEJS_DB_ELASTIC_APIKEY_ID`](/reference/configuration/environment-variables#cubejs_db_elastic_apikey_id)       | [ID of the API key from elastic.co][elastic-docs-api-keys]                                                                                                                               | A valid Elastic.co API key ID          |     ❌    |
| [`CUBEJS_DB_ELASTIC_APIKEY_KEY`](/reference/configuration/environment-variables#cubejs_db_elastic_apikey_key)     | [Value of the API key from elastic.co][elastic-docs-api-keys]                                                                                                                            | A valid Elastic.co API key value       |     ❌    |
| [`CUBEJS_DB_MAX_POOL`](/reference/configuration/environment-variables#cubejs_db_max_pool)                         | The maximum number of concurrent database connections to pool. Default is `8`                                                                                                            | A valid number                         |     ❌    |
| [`CUBEJS_CONCURRENCY`](/reference/configuration/environment-variables#cubejs_concurrency)                         | The number of [concurrent queries][ref-data-source-concurrency] to the data source                                                                                                       | A valid number                         |     ❌    |

[ref-data-source-concurrency]: /admin/connect-to-data/concurrency#data-source-concurrency

## SSL

Cube does not require any additional configuration to enable SSL as
Elasticsearch connections are made over HTTPS.

[elastic-co]: https://elastic.co/

[elastic-cloud]: https://cloud.elastic.co/

[elasticsearch]: https://www.elastic.co/elasticsearch/

[elastic-docs-api-keys]: https://www.elastic.co/guide/en/kibana/master/api-keys.html#create-api-key
