Keywords

The source of truth for the TypeQL keywords and grammar is the ANTLR v.4 specification file: TypeQL.g4.

Clauses

Clause keywords declare a start of a query’s clause:

define

Starts a define clause of a Define query.

undefine

Starts an undefine clause of a Undefine query

match

Starts a match clause that can be used in an Insert, Delete, Update, Fetch, or Get query.

insert

Starts an insert clause of an Insert query.

delete

Starts a delete clause of a Delete query.

fetch

Starts a fetch clause of a Fetch query.

get

Starts a get clause of a Get query.

Schema statements

Schema statement keywords used inside a clause of a query as a part of a data pattern or a schema definition:

sub

Specify a type as a subtype of a given type. Takes into account all subtypes of a given type. See an example.

sub!

Specify a type as a direct subtype of a given type. See an example.

type

Specify an exact type by its label. See an example.

abstract

Specify that a given type is an abstract type.

owns

Specify that a given type can own attributes of a given attribute type. See an example.

value

Specify a value type for an attribute type. See an example.

relates

Add a new role for a relation. See an example.

plays

Specify that a given type can play a given role (in a given relation). See an example.

@key

Add a key constraint to ownership of a given attribute type by a given type.

@unique

Add a uniqueness constraint to ownership of a given attribute type by a given type.

regex

Specify a regular expression that limits values of a given attribute type. See an example.

as

Override an inherited attribute type ownership or role. See an example.

when

Specify a condition of a rule.

then

Specify a conclusion of a rule.

Data statements

Data statement keywords used inside a clause of a data query as a part of a data pattern:

isa

Specify a type for a data instance. Takes into account all subtypes of a given type. See an example.

isa!

Specify a type for a data instance without taking into account its subtypes. See an example.

is

Specify an equality between two concepts. See an example.

has

Specify an ownership of a given attribute by a given instance. See an example.

Modifiers

offset

Offset the result of a query by the specified number of results. See an example.

limit

Limit the result of a query by the specified number of results. See an example.

sort

Sort the results of a query. See an example.

Logic

or

Specify a disjunction between two sets of statements surrounded by curly brackets. See an example.

not

Specify a negation of a set of statements surrounded by curly brackets. See an example.

Value comparators

==

Specify that values are equal.

!=

Specify that values are not equal.

>

Specify that the first value is bigger than the second one.

<

Specify that the first value is smaller than the second one.

>=

Specify that the first value is bigger or equal than the second one.

<=

Specify that the first value is smaller or equal than the second one.

like

Specify that value matches a given regular expression. See an example.

contains

Specify that value contains a given substring. See an example.

Aggregation

group

Group results by a given variable. See an example.

count

Count the number of results. See an example.

max

Find maximum value of a given variable. See an example.

min

Find minimum value a given variable. See an example.

mean

Find average value a given variable. See an example.

median

Find median value a given variable. See an example.

std

Find standard deviation a given variable. See an example.

sum

Find sum of values for a given variable. See an example.

Provide Feedback