kaquel.kql – KQL related utilities

See Kibana Query Language for more information.

kaquel.kql.parse_kql(kuery: str, /, *, allow_leading_wildcards: bool = True, filters_in_must_clause: bool = False) Query

Parse a KQL expression into an ElasticSearch query.

Parameters:
  • kuery – KQL expression to parse.

  • allow_leading_wildcards – Whether to allow leading wildcards.

  • filters_in_must_clause – Whether filters should be in the ‘filter’ or ‘must’ clause.

Returns:

Parsed query.

Raises:
kaquel.kql.render_as_kql(query: Query, /, *, filters_in_must_clause: bool = False) str

Render the query as a KQL query.

Parameters:
  • query – Query to render as KQL.

  • filters_in_must_clause – Whether filters should be retrieved from the ‘must’ clause rather than ‘filter’ clause for boolean queries.

Returns:

Rendered query as KQL.

Raises:

RenderError – An error has occurred while rendering the query; usually, the query makes use of a feature that cannot be translated into KQL.