GQL Query Language¶
GQL (Graph Query Language) is the ISO standard for querying property graphs (ISO/IEC 39075). Grafeo implements GQL as its primary query language.
Overview¶
GQL uses pattern matching to query and manipulate graph data. The syntax is very similar to Cypher.
Quick Reference¶
| Operation | Syntax |
|---|---|
| Match nodes | MATCH (n:Label) |
| Match edges | MATCH (a)-[:TYPE]->(b) |
| Filter | WHERE n.property > value |
| Return | RETURN n.property |
| Create | INSERT (:Label {prop: value}) |
| Update | SET n.property = value |
| Delete | DELETE n / DETACH DELETE n |
| Conditional | CASE WHEN ... THEN ... END |
| Cast | CAST(expr AS type) |
| Unwind list | UNWIND [1, 2, 3] AS x |
| For loop | FOR x IN $items |
| Combine queries | ... UNION ALL ... |
| Call procedure | CALL name(args) YIELD field |
| Call subquery | CALL { MATCH ... RETURN ... } |
| Create type | CREATE NODE TYPE Name (...) |
| Create index | CREATE INDEX FOR (n:Label) ON (n.prop) |
| Transaction | START TRANSACTION READ ONLY |
Learn More¶
-
MATCH, RETURN, OPTIONAL MATCH, WITH, LET, CALL and query composition.
-
Node and edge patterns, label expressions, path quantifiers, search prefixes and path modes.
-
WHERE clauses, comparison operators, LIKE, type checking and graph predicates.
-
CASE, CAST, COALESCE, list comprehensions, reduce and subquery expressions.
-
COUNT, SUM, AVG, STDEV, percentiles, GROUP BY and HAVING.
-
Variable-length paths, shortest paths, path modes and path predicates.
-
INSERT, SET, DELETE, MERGE and label operations.
-
UNION, EXCEPT, INTERSECT and OTHERWISE for combining query results.
-
String manipulation: toUpper, replace, split, substring and more.
-
Math functions: abs, sqrt, log, trigonometry and constants.
-
Date, time, datetime, duration, zoned temporals and arithmetic.
-
Identity, labels, properties, path decomposition and list utilities.
-
Data types, typed literals, type checking, CAST and three-valued logic.
-
Graph management, type definitions, indexes, constraints and stored procedures.
-
Transaction control, isolation levels and session configuration.