An introduction to Graql
Edit me

Graql enables users to write queries against a Grakn graph 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 graph traversals needed to retrieve information.

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

Query types

There are five types of queries, which are begun with the following keywords:
- match - for matching patterns in the graph
- ask - for querying if certain patterns exist in the graph
- insert - for inserting types and instances
- delete - for deleting types and instances
- compute - for computing useful information about your graph

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
limit
match
offset, order
regex
select
to
value

Datatypes

datatype
boolean, double, long, string
true, false

Ontology definition

has, has-key, has-resource, has-role, has-scope
is-abstract, isa
plays, plays-role

Rules definition

lhs, rhs

Statistics with compute and aggregate

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

Graql templates

and
do
else, elseif
for
if, in
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!

Comments

Want to leave a comment? Visit the issues on Github for this page (you’ll need a GitHub account). You are also welcome to contribute to our documentation directly via the “Edit me” button at the top of the page.

Tags: graql