GQL Query Language Reference

Geode implements the ISO/IEC 39075:2024 Graph Query Language (GQL) 100% compliance. See the conformance profile for scope and diagnostics.

Overview

GQL is a declarative query language specifically designed for property graph databases. It provides powerful pattern matching capabilities, expressive syntax for graph traversals, and comprehensive data manipulation operations.

Key Features

  • Pattern Matching: Express complex graph patterns with intuitive syntax
  • Variable-Length Paths: Traverse relationships with flexible path lengths
  • Aggregations: Built-in aggregate functions for analytics
  • Transactions: Full ACID compliance with MVCC isolation
  • Advanced Types: Support for 50+ specialized data types
  • Set Operations: UNION, INTERSECT, EXCEPT for combining query results

Basic Query Structure

-- Simple pattern match
MATCH (n:Person)
WHERE n.age > 30
RETURN n.name, n.age
ORDER BY n.age DESC
LIMIT 10

Quick Reference

Pattern Matching

-- Node pattern
(n:Label {property: value})

-- Relationship pattern
-[:TYPE]->

-- Path pattern
(a)-[:KNOWS*1..3]->(b)

Data Modification

-- Create node
CREATE (p:Person {name: 'Alice', age: 30})

-- Create relationship
MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CREATE (a)-[:KNOWS {since: 2024}]->(b)

-- Update properties
MATCH (p:Person {name: 'Alice'})
SET p.age = 31

-- Delete
MATCH (p:Person {name: 'Alice'})
DELETE p

Aggregations

-- Count
MATCH (n:Person)
RETURN count(n)

-- Group by
MATCH (p:Person)
RETURN p.city, count(*) AS population
GROUP BY p.city
ORDER BY population DESC

Reference Topics

Detailed reference documentation for GQL:

For comprehensive GQL coverage, see also:

ISO/IEC 39075:2024 Conformance Profile

Geode publishes the ISO GQL conformance profile:

  • ✅ Deterministic ordering and pagination policies
  • ✅ MATCH pattern matching with bounded expansions and OPTIONAL MATCH
  • ✅ Aggregations and set operations
  • ✅ Transaction semantics
  • ✅ Diagnostics aligned to the conformance profile

Examples

Find Friends of Friends

MATCH (me:Person {name: 'Alice'})-[:KNOWS*2]->(fof:Person)
WHERE fof <> me
RETURN DISTINCT fof.name

Shortest Path

MATCH path = shortestPath((a:City {name: 'Seattle'})-[*]-(b:City {name: 'Boston'}))
RETURN path, length(path) AS hops

Social Network Analysis

MATCH (p:Person)-[:POSTED]->(post:Post)
WHERE post.timestamp > timestamp('2024-01-01')
RETURN p.name, count(post) AS posts
ORDER BY posts DESC
LIMIT 10

Next Steps

Pages