Skip to main content

BQL Operators

This article details the operators in Brinqa Query Language (BQL) that can be used to specify conditions and perform tasks in a query.

DISTINCT

You may come across situations where a query generates unneeded duplicates. This occurs if there are multiple paths of traversal between the entities referenced in the query.

You can use DISTINCT to only return discrete values or make all values unique before running them through an aggregate function. You can combine the DISTINCT and RETURN keywords to help remove duplicates. For example:

FIND Vulnerability AS v RETURN DISTINCT v.riskRating, count(*)

The above query counts the number of vulnerabilities by their risk rating. Without using DISTINCT, the query selects all values and may return duplicate results.

Boolean Operators

You can use the Boolean operators as conjunctions to combine or exclude conditions in a query. The following table describes the Boolean operators in BQL:

Table 1: Boolean Operators

OperatorOperators SymbolExample
AndAND, &FIND Finding WHERE riskRating = "Critical" AND severity = "Critical"
You can use AND and & interchangeably when querying for "and".
OrORFIND Asset WHERE category = ”Host” OR category = ”Virtual Machine”
NotNOTFIND Finding WHERE firstFound NOT IN LAST 3 months

Comparison operators

The comparison operators in BQL work for all attribute types. They compare values and return true or false.

note

You must use the comparison operator symbol (for example, >) rather than the name of the symbol (GREATER THAN) in the query. Using names of the operators is not supported.

The following table describes the comparison operators in BQL:

Table 2: Comparison operators

OperatorOperators SymbolExample
Equals To=FIND Finding WHERE riskRating = "Critical"
Not Equal To!=, <>FIND Finding WHERE severity != "Critical"
FIND Finding WHERE severity <> "Critical"
You can use != and <> interchangeably when querying for "not equal to".
Greater Than>FIND Finding WHERE severity > "High"
Less Than<FIND Finding WHERE riskRating < "Critical"
Greater Than Or Equals To>=FIND Finding WHERE riskScore >= 4
Less Than Or Equals To<=FIND Finding WHERE riskRating <= "Low"

Attribute operators

The attribute operators in BQL can work with any attribute type.

caution

Attribute operators must be used with attributes from the same data model. They cannot be used across different data models.

The following table describes the attributes operators in BQL:

Table 3: Attribute operators

OperatorSyntaxExamples
Equals to Attributeattribute1 EQUALS TO ATTRIBUTE attribute2FIND Finding WHERE riskScore EQUALS TO ATTRIBUTE baseRiskScore
Not Equals to Attributeattribute1 NOT EQUALS TO ATTRIBUTE attribute2FIND Finding WHERE riskScore NOT EQUALS TO ATTRIBUTE baseRiskScore
Greater Than Attributeattribute1 GREATER THAN ATTRIBUTE attribute-name attribute2FIND Finding WHERE riskScore GREATER THAN ATTRIBUTE baseRiskScore
Less Than Attributeattribute1 LESS THAN ATTRIBUTE attribute-name attribute2FIND Finding WHERE riskScore LESS THAN ATTRIBUTE baseRiskScore
Greater Than or Equals to Attributeattribute1 GREATER THAN OR EQUALS TO ATTRIBUTE attribute-name attribute2FIND Finding WHERE riskScore GREATER THAN OR EQUALS TO ATTRIBUTE baseRiskScore
Less Than or Equals to Attributeattribute1 LESS THAN OR EQUALS TO ATTRIBUTE attribute-name attribute2FIND Finding WHERE riskScore LESS THAN OR EQUALS TO ATTRIBUTE baseRiskScore
Existsattribute EXISTSFIND Asset WHERE firstSeen EXISTS
Not Existsattribute NOT EXISTSFIND Finding WHERE dueDate NOT EXISTS

Date and Time operators

The date and time operators in BQL can work with attributes whose type is Date, DateTime, Time, or any other calculated attribute that returns these attribute types.

note

BQL only allows for the date format of YYYY-MM-DD. For example, 2022-04-20.

The following date and time units are supported. They are not case sensitive and do not need to be wrapped in quotes:

  • ms, milli, millis, milliseconds
  • s, second, seconds
  • minute, minutes
  • hour, hours
  • day, days
  • week, weeks
  • month, months
  • year, years

The date and time operators are not case sensitive. The following tables describes the date and time operators in BQL:

Table 4: Date and Time operators

OperatorSyntaxExamples
IsIS dateFIND Ticket WHERE lastUpdated IS 2017-01-31
Is NotIS NOT dateFIND Ticket WHERE lastUpdated IS NOT 2017-01-31
SinceSINCE dateFIND Vulnerability WHERE lastUpdated SINCE 2022-02-02
BeforeBEFORE dateFIND Vulnerability WHERE lastUpdated BEFORE 2022-02-02
BetweenBETWEEN [date1 TO date2]FIND Finding WHERE dateCreated BETWEEN [ 2016-01-01 TO 2022-07-12 ]
Not BetweenNOT BETWEEN [date1 TO date2]FIND Finding WHERE dateCreated NOT BETWEEN [ 2016-01-01 TO 2022-07-12 ]
In NextIN NEXT dateFIND Ticket WHERE dueDate IN NEXT 1 month
Not In NextNOT IN NEXT dateFIND Ticket WHERE dueDate NOT IN NEXT 3 weeks
In LastIN LAST dateFind Vulnerability WHERE dateCreated IN LAST 1 day
Not In LastNOT IN LAST dateFIND Vulnerability WHERE dateCreated NOT IN LAST 1 month

String operators

BQL offers a variety of string operators to compare strings stored either as a single string or multi-value field.

note
  • BQL only supports using the name of the string operator in a query (for example, CONTAINS rather than ~= or STARTS WITH rather than ^=).

  • The string must be wrapped in double quotes ("").

The following table describtes the string operators in BQL:

Table 5: String operators

OperatorSyntaxExamples
ContainsCONTAINS "string"FIND Asset WHERE name CONTAINS "demo"
Not ContainsNOT CONTAINS "string"FIND Finding WHERE severity NOT CONTAINS "Low"
LikeLIKE "string"FIND Asset WHERE name LIKE "demo*"
LIKE is similar to CONTAINS, but also allows wildcard characters.
Not LikeNOT LIKE "string"FIND Asset WHERE name NOT LIKE "demo*")
Starts WithSTARTS WITH "string"FIND Asset WHERE name STARTS WITH "demo"
Does Not Start WithNOT STARTS WITH "string"FIND Asset WHERE name NOT START WITH "demo"
Ends WithENDS WITH "string"FIND Asset WHERE createdBy ENDS WITH "admin"
Does Not End WithNOT ENDS WITH "string"FIND Asset WHERE createdBy NOT ENDS WITH "admin"

List operators

List operators check if an element exists or does not exist in a list. The following table describtes the List operators in BQL:

Table 6: List operators

OperatorSyntaxExamples
InIN [value1, value2]FIND Finding WHERE severity IN ["Critical", "High"]
Not InNOT IN [value1, value2]FIND Finding WHERE severity NOT IN ["Critical", "High"]
Contains AnyCONTAINS ANY [term1, term2]FIND Finding WHERE severity CONTAINS ANY ["Critical", "High", "Medium"]
Contains AllCONTAINS ALL [term1, term2]FIND Host WHERE privateIpAddress CONTAINS ALL [ "127.0.0.1", "127.0.0.2" ]
Does Not Contain AnyNOT CONTAINS ANY [term1, term2]FIND Finding WHERE riskRating NOT CONTAINS ANY ["Critical", "Low"]
Contains None OfNOT CONTAINS ALL [term1, term2]FIND Host WHERE privateIpAddress NOT CONTAINS ALL [ "127.0.0.1", "127.0.0.2" ]

Security operators

Security operators can be used with attributes whose type is related to a user or any calculated attributes that return a user. The following table describes the security operators in BQL:

Table 7: Security operators

OperatorSyntaxExamples
Is Current UserIS CURRENT USERFIND Asset AS a THAT OWNS Person AS u WHERE u IS CURRENT USER