Query your Elasticsearch data with more flexibility using DSL and ES|QL
Go beyond the visual query builder in Elasticsearch with a new raw query editor and support for two query languages: Elasticsearch Query DSL and ES|QL.
With Elasticsearch Query DSL, you can write advanced queries with complex nested aggregations, custom scoring, or any query structure that the visual editor can’t express. Template variables and built-in macros like $\_\_interval and $\_\_interval_ms are interpolated as expected in raw DSL queries.
ES|QL, the Elasticsearch piped query language, is a more expressive and readable alternative to the builder and raw DSL where you can filter, transform, and aggregate your data.
ES|QL queries aren’t tied to the index configured in the data source. This means you can query any index directly in the FROM clause, making a single data source usable across multiple indices. If an index is configured, the editor pre-populates FROM $__index as a starting point and the backend resolves this placeholder to the configured index name at query time. This way, the same query works portably across different data source configurations without any edits.
Enable the elasticsearchRawDSLQuery and elasticsearchESQLQuery feature toggles to use the DSL and ES|QL features, respectively. To learn more, refer to the documentation.