An introduction to Graql
Edit me

Graql enables users to write queries against a Grakn knowledge base leveraging the inherent semantics of the data. Concepts can be retrieved by specifying the patterns of types and relationships that identify them. Graql is declarative and therefore it handles the optimisation of the knowledge base queries needed to retrieve information.

You can execute Graql in the Graql Shell or using Java Graql.

Query types

There are several types of queries, which are begun with the following keywords:

  • get - for finding patterns in the knowledge base
  • define - for defining schema concepts
  • insert - for inserting data
  • delete - for deleting schema concepts and data
  • compute - for computing useful information about your knowledge base

Reserved keywords

The following list Graql’s reserved keywords:

Querying and query modifiers

aggregate, asc, ask
by
compute, contains
delete, desc, distinct
from
id, in, insert
label, limit
match
offset, order
regex
select
to
val

Datatypes

datatype
boolean, double, long, string, date
true, false

Schema definition

has,
is-abstract, isa, 
key,
plays,
relates

Rules definition

when, then

Statistics

Used with compute and aggregate:

count
group
max, mean, median, min
std, sum

Graql templates

and
concat
do
else, elseif
for
if, in
noescp, not, null
true, false

Cheatsheet reference

If you are already familiar with Graql, you may find our cheatsheet reference a helpful page to bookmark or print out!

Tags: graql