Skip to content

Logical Expressions

Logical expressions are used in QQL to combine and evaluate boolean conditions, typically in commands like where and eval. They support logical operators such as AND, OR, and NOT, as well as grouping with parentheses.

Description

A logical expression allows you to combine multiple boolean conditions using logical operators. This enables you to build complex filters and computed fields based on your data.

Supported logical operators:

  • && (AND): Both conditions must be true.
  • || (OR): At least one condition must be true.
  • ! (NOT): Negates a condition.
  • Parentheses () can be used to group expressions and control precedence.
  • Compare operators like ==, !=, <, >, <=, >= can be used within logical expressions.

Logical expressions can be nested and combined with comparison operators and functions.

Syntax

where logical_expression

A logical expression can be:

  • A comparison: field == value
  • A function: isNull(field)
  • A combination: (field1 == "foo" && field2 > 10) || isNull(field3)

Usage Examples

Simple AND:

where status == "error" && duration > 1000

Simple OR:

where status == "error" || status == "warn"

Negation:

where !(level == "info")

Grouping:

where (status == "error" || status == "warn") && duration > 1000

With functions:

where isNull(optional_field) || contains(message, "timeout")

Logical expressions are parsed and evaluated according to standard boolean logic, with parentheses controlling precedence.