Query external datasets with ES|QL Data Federation
A dataset is a read source for the standard ES|QL pipeline. You query it with FROM like an index, and every processing command works the same way it does for an index.
FROM my_dataset
For a hands-on example, refer to get started with ES|QL Data Federation.
When you query a dataset, Elasticsearch reads data from object storage (such as Amazon S3) rather than from a local index. This means every column and every row that a query touches results in network I/O. The query engine applies several optimizations automatically, and there are things you can do to help it read less data.
Use KEEP or DROP to select only the columns your query needs. For Parquet files, column selection pushes down to the reader so that unrequested columns are never fetched from storage. For CSV and NDJSON, the full row is read but unrequested columns are discarded early.
In practice, this can make a significant difference. A filtered query over a Parquet dataset that selects three columns reads roughly a third of the bytes that the same query reads without column selection.
When a dataset's resource path uses Hive-style partitioning (for example, year=2024/month=3/), the engine detects partition keys automatically and promotes them to queryable columns. A WHERE condition on a partition column evaluates during file discovery, before any data is read. On a two-year monthly-partitioned dataset, WHERE year = 2024 AND month = 3 skips 23 out of 24 partitions at zero I/O cost.
Pruning applies when the partition filter comes before any LIMIT, SORT, or STATS in the query. If one of those commands sits between FROM and the WHERE on a partition column, pruning is silently skipped and every partition is read. Try to put partition filters first.
For details on partition detection modes, refer to dataset settings.
WHERE conditions and LIMIT reduce how much data a query reads, but how far they push down depends on the format. For Parquet files, filters push down into the reader itself: the engine uses row-group statistics and page indexes to skip data that cannot match the filter. Only row groups whose statistics overlap the filter condition are read, and within those row groups, late materialization reads predicate columns first and materializes other columns only for rows that survive the filter.
For CSV and NDJSON, filters do not reach the reader: every row must be read and parsed, but rows that fail the filter are discarded before further processing.
FROM access_logs
| WHERE status_code >= 500
| KEEP @timestamp, status_code, request_path
| LIMIT 100
The general query performance advice in optimize ES|QL query performance applies to datasets too. In particular, adding a WHERE, a KEEP, and a LIMIT are the three most effective ways to reduce how much data a query reads from storage.
Elasticsearch caches file metadata (schemas and file listings) so that repeated queries against the same dataset do not re-discover files each time. Cached schemas are invalidated when the underlying files change, so a schema stays cached for as long as it stays correct. There is no schema TTL. Only the file-listing cache uses a TTL (5 minutes by default) configurable through cluster settings.
A dataset's resource path can use glob patterns to match many files. These cluster settings bound file discovery:
esql.external.max_listed_objects(default 1,000,000): the maximum number of objects visited while listing a glob, including keys that do not match the pattern and keys dropped by exclusion. Applied independently to each glob listing. A comma-separated resource of N globs therefore does N listings; a rewrite-empty fallback can list the same glob again. The kept-files cap (esql.external.max_discovered_files) is shared across that list.esql.external.max_discovered_files(default 25,000): the maximum number of files a single dataset keeps after listing filters (_file.*).esql.external.max_glob_expansion(default 100): the maximum number of concrete paths a brace pattern ({a,b,c}) expands to. Past this cap, the engine falls back to listing the storage instead of failing.
If your dataset exceeds these limits, narrow the resource path or adjust the settings. Refer to cluster settings for details.
Datasets share the same namespace as indices, data streams, aliases, and ES|QL views, so FROM resolves each name independently.
_class and _name are available from 9.6. On 9.5, use METADATA _index, which returns the dataset name for dataset rows in that version.
FROM speedtest_data, network_incidents METADATA _class, _name
| KEEP _class, _name, category, severity, avg_d_kbps, avg_lat_ms
| LIMIT 10
When sources have different schemas, columns that do not exist in a given source return null for rows from that source.
METADATA _name to see which source each row came from: it returns the dataset name for dataset rows and the index name for index rows. METADATA _class returns what kind of source a row came from — index or dataset — so a query can tell the two apart without knowing the names in advance.
_index does not answer this question on a dataset. It names an index, and a dataset is not one, so it returns null for dataset rows. In earlier versions it returned the dataset name.
FROM speedtest_data reads the dataset, while FROM speedtest* resolves to indices, data streams, aliases, and views only. Registering a dataset therefore does not change what an existing wildcard query reads.
To let wildcards discover datasets, enable the wildcards_match_datasets query setting:
SET wildcards_match_datasets = true;
FROM speedtest*
You can also send it in the _query request body as "settings": {"wildcards_match_datasets": true}, or change the cluster-wide default with esql.query.settings.wildcards_match_datasets. A value set in the query overrides the request body, which overrides the cluster default.
Metadata columns are available using the METADATA directive:
| Column | Returned for a dataset |
|---|---|
_class
|
dataset |
_name
|
The dataset name. |
_file.path, _file.name, _file.directory, _file.size, _file.modified |
The object each row was read from. |
_ignored |
null |
_index_mode, _tsid, _size |
null |
_score
|
0.0, or a real per-row value under a scoring MATCH/MATCH_PHRASE. See Use search functions. (Returns null in 9.5.) |
_index
|
null |
_id, _version, _source
|
null |
_index, _id, _version and _source return null on a dataset. A dataset is not an index, and
files carry no document identity, version, or stored source. In 9.5, these fields returned synthetic
values (dataset name, row ID, file modification time, row-as-JSON) instead of null.
_class and _name answer the same two questions on every source. On an index they return index and
the concrete index name; on a dataset, dataset and the dataset name. A FROM that names both kinds
can separate the rows without knowing in advance which names resolve to which.
For example, this query returns file-level metadata for each matching row:
FROM access_logs METADATA _file.path, _file.name, _file.size
| KEEP _file.path, _file.name, _file.size, status_code
| LIMIT 10
METADATA clause matches a file column, the engine-generated value takes precedence and the file column is dropped. A warning identifies the file column that was dropped. To keep both values, rename the file column in the dataset mapping. If the query omits METADATA, the file column remains available as a regular data column.
Search functions can filter dataset rows by evaluating the query against values read from the files. This runtime search does not use an inverted index. When using METADATA _score, MATCH and MATCH_PHRASE on dataset rows contribute to the relevance score based on the boost option and the query terms matched — not BM25, as there are no index statistics for a dataset.
_score.
Because there is no inverted index, search functions on a dataset evaluate by scanning values row by row. For large datasets where search is the primary access pattern, consider ingesting the data into Elasticsearch for indexed search performance.
Runtime MATCH on a dataset requires the query value's type to match the field's type. Text is analyzed with the standard analyzer unless a values analyzer is declared through TO_TEXT's analyzer option; MATCH's own analyzer option applies to the query string only, defaulting to the values analyzer.
The following search functions are available for datasets:
| Function | Stack |
|---|---|
MATCH |
|
MATCH_PHRASE |
|
_score for dataset rows |
|
This feature is experimental. It is not intended for production use and there are no guarantees around performance, scale, or stability in this release.
The limitations below include operations that require structures available only in an Elasticsearch index, such as the inverted index, doc values, or time series metadata, as well as unsupported data shapes. Unsupported operations fail with a clear error; representation limitations are described in the table.
| Operation | Reason | Error |
|---|---|---|
LOOKUP JOIN, with a dataset as the lookup target |
A dataset works as the left (source) side of the join. The lookup target must be an Elasticsearch index. | LOOKUP JOIN against a dataset is not supported; dataset(s) requested: [...] |
TS (time series) |
A time-series source must be an Elasticsearch index. | TS command is not supported for datasets; dataset(s) requested: [...] |
| Search functions | Search functions work on datasets as runtime search functions, scanning values row by row without an inverted index. Availability varies by version and deployment type. Refer to the availability table. | … cannot operate on [<field>], which is not a field from an index mapping (the source is a federated data source, not an index) |
KNN |
KNN requires a vector field from an index mapping, which a dataset does not have. |
… cannot operate on [<field>], which is not a field from an index mapping (the source is a federated data source, not an index) |
More than 8 sources resolved in one FROM |
A FROM that includes datasets runs one execution branch per resolved source, up to a limit of 8 branches. Query fewer sources together. |
|
| A column with conflicting types across sources | When you query a dataset together with other sources and the same column has types that cannot be reconciled, the query fails rather than returning mixed types. | Column [<name>] has conflicting data types in subqueries |
A file column whose name matches a requested METADATA name
|
The engine-generated value replaces the file column. Rename the file column in the dataset mapping to keep both. | A warning names the dropped column. |
| Document-level security (DLS) and field-level security (FLS) | A dataset's read grant cannot carry document- or field-level security. Queries where DLS or FLS applies to a dataset are rejected during authorization. The same check covers ES|QL views. |
Datasets with document or field level security restrictions are not supported. Remove DLS/FLS restrictions from the affected datasets in the role definition, or exclude them from the request. |
| Cross-cluster search | Only local datasets can be queried.
skip_unavailable setting decides whether the query fails or that cluster is skipped. In earlier versions, a query that matched a remote dataset failed. |
Unknown index [<cluster>:<dataset>], when skip_unavailable is false. In earlier versions, ES\|QL queries with remote datasets are not supported. Matched [...] |
| Snapshot and restore | Data sources and datasets cannot be snapshotted or restored. | |
| Archived S3 storage classes | Objects in the S3 Glacier Flexible Retrieval or S3 Glacier Deep Archive storage classes cannot be read in real time. The same applies to objects that have transitioned to the Archive Access or Deep Archive Access tiers within S3 Intelligent-Tiering. Objects in other Intelligent-Tiering tiers are not affected. A GetObject call to archived objects returns InvalidObjectState until the object is restored. Restore the objects before querying. S3 Glacier Instant Retrieval is also not affected because it supports real-time access. |
|
| Parquet MAP, nested LIST, and VARIANT | These complex types are not currently supported and return null. STRUCT is supported and flattened to dot-notation column names (for example, address.city). |
|
null elements inside a Parquet LIST |
An ES|QL multivalued field cannot hold null, so a null element inside a list is omitted and the column returns fewer values than the file holds. A list of [1, null, 2] reads as [1, 2], and a list whose elements are all null reads as null. The response includes a warning naming the affected columns. |
If a query against a dataset returns unexpected results or errors, check the following common causes.
- Unexpected nulls in query results
- If you query a dataset and an index together with
FROM, columns that do not exist in one source return null for rows from that source.Use METADATA _nameto check which source each row came from; on 9.5, useMETADATA _index. Separately, complex Parquet types MAP, nested LIST, and VARIANT return null because they are not currently supported. - Slow queries
- Add
KEEPto select only the columns you need, add aWHEREfilter, and add aLIMIT. For Parquet datasets, these push down to the reader and can significantly reduce the amount of data read from storage. Check the number of files your dataset's resource path resolves to. Large file counts increase query planning time. - 503 error when creating a data source with credentials
- Elasticsearch encrypts credentials before storing them. If the cluster state encryption key is not available, the request returns
503 SERVICE_UNAVAILABLE. Refer to credential encryption for details. - New files not appearing in query results
- Elasticsearch caches file listings for each dataset. A file added to or removed from the bucket might not show up until the listing cache expires. The default listing cache TTL is 5 minutes. Lower
esql.external.cache.listing.ttlwhen new or removed files must be visible sooner. Refer to cluster settings. - Columns with unexpected types or missing values
- When Elasticsearch infers a dataset's schema from its files, it might infer types differently than you expect. For example, a date column might appear as a keyword if the values do not match the default datetime format. To inspect the inferred field mappings, refer to check field mappings in the quickstart. Use dataset mappings to declare column types explicitly, or adjust the
datetime_formatsetting. If some rows have null values for a column that exists in other files, check the dataset'sschema_resolutionsetting. - Access denied or connection errors
- Credential and permission errors appear at query time, not when the data source is created. If a query returns an access denied error, verify that the credentials in the data source have the required permissions (such as
s3:ListBucketands3:GetObject) and that the region is correct.
- To adjust caching TTLs, file-discovery limits, or request concurrency, refer to cluster settings.
- To control column types or rename columns, declare dataset mappings.
- For general ES|QL tuning advice that also applies to datasets, refer to optimize ES|QL query performance.