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 xorIN staff AS x) to reference and filter their properties inWHEREclauses. - 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:
- FIND PATTERN basics: declare node aliases, link via bond labels, and apply filters with WHERE.
- Edge directions: control traversal orientation using TO, FROM, and WITH.
- Cross-bucket patterns: trace complex multi-hop relationships across multiple distinct buckets.
- Bond history (FIND HOW): inspect how relationship bonds change and drift across historical timestamps.
