Getting Started

Tutorial: Building with CleaveDB

Pattern Matching — Overview

While simple graph traversals like FOLLOW and TRACE begin at a single known document, complex domain questions often describe an entire multi-node structural pattern across different buckets and edge labels. CleaveQL introduces FIND PATTERN for declarative subgraph matching and FIND HOW for auditing relationship drift over time.

Core Pattern Matching primitives

  • Node Aliasing: Define node variables within buckets (e.g., staff AS x or IN staff AS x) to reference and filter their properties in WHERE clauses.
  • Bonds via LINKED VIA: Connect nodes by relationship label using LINKED VIA "label".
  • Directional Prepositions: Control edge flow explicitly:
    • TO (outgoing →): the left node targets the right node.
    • FROM (incoming ←): the right node targets the left node.
    • WITH (undirected ↔): matches mutual or two-way relationships.
  • Cross-Bucket Chains: Seamlessly stitch relationships across different collections, such as users, orders, and products.
  • Bond Drift History (FIND HOW): Query the chronological timeline of when relationships were established (LINK) or destroyed (SEVER) within any time window.

Explore the Pattern Matching topics

Step through the tutorials below to learn canonical CleaveQL pattern matching: