There are use cases for making programmatic edits to an ES|QL query. For example, adding or changing a where clause when a user filters by a field (ref).
We have code to parse an ES|QL string to an AST (a reader), but no code for the inverse (a generator).
This leaves us no choice but to use string manipulation.
Instead, we should provide a generator so that edits can be made to the AST and then serialized into a new query. This is a more robust and less error-prone method of manipulating queries.
There are use cases for making programmatic edits to an ES|QL query. For example, adding or changing a
where
clause when a user filters by a field (ref).We have code to parse an ES|QL string to an AST (a reader), but no code for the inverse (a generator).
This leaves us no choice but to use string manipulation.
Instead, we should provide a generator so that edits can be made to the AST and then serialized into a new query. This is a more robust and less error-prone method of manipulating queries.