Create and manage datasets with the Elasticsearch API

Datasets are managed under the /_query/dataset endpoint. All dataset operations require the index manage privilege on the dataset name, or a fine-grained dataset privilege. Refer to manage credentials and privileges for details.

Operation Endpoint API reference
Create or update PUT /_query/dataset/{name} Create or update an ES|QL dataset
Get GET /_query/dataset/{name} Get ES|QL datasets
List all GET /_query/dataset Get ES|QL datasets
Open POST /_query/dataset/{name}/_open Open an ES|QL dataset
Close POST /_query/dataset/{name}/_close Close an ES|QL dataset
Delete DELETE /_query/dataset/{name} Delete ES|QL datasets

This page is a quick reference for each operation. For the complete request and response details, follow the API reference links in the table.

PUT /_query/dataset/{name} creates a new dataset or replaces an existing one entirely.

A dataset cannot have the same name as an existing index, data stream, alias, or view, because dataset names share the same namespace. Dataset names must be lowercase and cannot begin with -, _, or +.

The optional description can be at most 1,000 characters long.

For restrictions on S3 bucket names, aliases, and Amazon Resource Names (ARNs), refer to Amazon S3 resource restrictions.

				PUT /_query/dataset/access_logs
					{
  "data_source": "prod_s3_logs",
  "resource": "s3://logs-bucket/access/**/*.parquet",
  "description": "Production access logs",
  "settings": {
    "partition_detection": "hive"
  }
}
		
curl -X PUT "${ELASTICSEARCH_URL}/_query/dataset/access_logs" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
  "data_source": "prod_s3_logs",
  "resource": "s3://logs-bucket/access/**/*.parquet",
  "description": "Production access logs",
  "settings": {
    "partition_detection": "hive"
  }
}'
		

Elasticsearch validates setting values when you register the dataset, rather than waiting until the first query. A value that isn't supported, such as a multi-character delimiter, an unknown encoding, or a segment_size below the minimum, returns a 400 error that identifies the setting.

Note

Datasets registered before this validation was introduced continue to work without being revalidated. Replacing one of these datasets triggers validation, so correct any unsupported values in the replacement request.

After creating a dataset, verify the inferred schema by checking its field mappings.

GET /_query/dataset/{name} retrieves a dataset by name.

				GET /_query/dataset/access_logs
		
curl -X GET "${ELASTICSEARCH_URL}/_query/dataset/access_logs" \
  -H "Authorization: ApiKey ${API_KEY}"
		

GET /_query/dataset returns all registered datasets.

				GET /_query/dataset
		
curl -X GET "${ELASTICSEARCH_URL}/_query/dataset" \
  -H "Authorization: ApiKey ${API_KEY}"
		

Close a dataset to stop queries from reading it, for example to control cost, then open it again after investigation. Requires manage_dataset, manage, or all on the dataset name. GET responses include two fields: state is the state of the dataset itself, open or closed, and effective_state tells whether queries can read it. Creating a dataset opens it, and replacing a dataset keeps its current state. Closing a closed dataset, or opening an open one, succeeds and changes nothing.

A dataset is closed for queries when it is closed, or when its data source is closed. Closing a data source does not change its datasets, so a dataset on a closed data source keeps state: open and shows effective_state: closed:

{
  "datasets": [
    {
      "name": "access_logs",
      "data_source": "prod_s3_logs",
      "resource": "s3://logs/access/*.parquet",
      "state": "open",
      "effective_state": "closed"
    }
  ]
}
		

effective_state does not name the data source or say which of the two is closed, so it can be read with the same privileges as the dataset itself.

A closed dataset behaves as follows:

  • A query that names the dataset in FROM fails with a 400 error that says the dataset is closed. It does not say whether the dataset or its data source was closed.
  • A FROM wildcard skips the dataset silently, as it skips a closed index. A wildcard only reaches datasets when the wildcards_match_datasets query setting is on.
  • A query that is already running may finish, or fail if the node that reads the dataset starts after you close it.
  • You can still get, list, and replace the dataset.

To close or open datasets with a wildcard, such as POST /_query/dataset/*/_close, set action.destructive_requires_name to false. It is true by default, which rejects the request, as it does for closing and opening indices and for deleting datasets.

Closing and opening are refused until every node in the cluster supports them, for example during a rolling upgrade. Both actions are recorded in the audit log.

				POST /_query/dataset/access_logs/_close
		
				POST /_query/dataset/access_logs/_open
		

DELETE /_query/dataset/{name} deletes a dataset by name.

Deleting a dataset doesn't check whether an ES|QL view reads from it. Views that read from a deleted dataset fail when queried.

				DELETE /_query/dataset/access_logs
		
curl -X DELETE "${ELASTICSEARCH_URL}/_query/dataset/access_logs" \
  -H "Authorization: ApiKey ${API_KEY}"
		

After creating a dataset, query it with ES|QL. To change how the dataset selects or interprets files, return to define a dataset.