Back to Kibana

ES|QL Language library

src/platform/packages/shared/kbn-esql-language/README.md

9.4.02.7 KB
Original Source

ES|QL Language library

The general idea of this package is to provide comprehensive ES|QL functionality including low-level parsing, building, traversal, pretty-printing, manipulation features on top of a custom compact AST representation, and advanced language features such as validation, autocomplete, hover, and signature help.

Contents of the package

Core AST Functionality

At the lowest level, the package provides a parser that converts ES|QL text into an AST representation. Or, you can use the Builder class to construct the AST manually:

The Traversal API lets you walk the AST. The Walker class is simple to use, while the mutate utilities provide more powerful manipulation capabilities:

The Pretty-printing API lets you format the AST to text:

Language Features

Advanced ES|QL language features including editor support:

  • language — Validation, autocomplete, hover, and signature help
    • language/validation — ES|QL query validation logic
    • language/autocomplete — Autocomplete and suggestion services
    • language/hover — Hover information providers
    • language/signature_help — Function signature assistance
    • language/inline_suggestions — Inline suggestion features

Commands and Query Building

The Commands registry allows you to register and manage ES|QL commands:

The Composer API provides a high-level, secure, and developer-friendly way to build ES|QL queries:

Demo

Much of the functionality of this package is demonstrated in the demo UI. You can run it in Storybook, using the following command:

bash
yarn storybook esql_ast_inspector

Alternatively, you can start Kibana with Example Plugins enabled, using:

bash
yarn start --run-examples

Then navigate to the ES|QL AST Inspector plugin in the Kibana UI.

Keeping ES|QL AST library up to date

In general when operating on changes here use the yarn kbn watch in a terminal window to make sure changes are correctly compiled.