OpenCypher Querying¶
Uni uses OpenCypher as its primary query language, with extensions for vector search, time travel, and admin procedures. This keeps graph queries expressive and readable.
What It Provides¶
- Pattern matching for nodes and relationships, including
OPTIONAL MATCHfor left-outer-join semantics. - Aggregations, ordering, filtering, and window functions (
OVERclause). MERGEfor upsert operations withON CREATE SET/ON MATCH SET.SET/REMOVEfor updating properties and labels on existing nodes and relationships.- Procedure calls for algorithms, snapshots, and indexes.
Example¶
use uni_db::Uni;
# async fn demo() -> Result<(), uni_db::UniError> {
let db = Uni::open("./my_db").build().await?;
let session = db.session();
let results = session
.query_with("MATCH (p:Person) WHERE p.age > $min RETURN p.name")
.param("min", 30)
.fetch_all()
.await?;
println!("{:?}", results);
# Ok(())
# }
Use Cases¶
- Relationship queries and graph traversals.
- Pattern matching with filters and aggregations.
- Admin and metadata procedures.
When To Use¶
OpenCypher is the best choice when your data model is graph-shaped and you need expressive relationship queries, not just key-value lookups or SQL tables.
Locy Integration¶
When you need recursive rule-based reasoning, hypothetical analysis, or abductive remediation workflows, use Locy on top of Cypher.
- Start at Locy Overview
- Learn syntax in Locy Language Guide
- See advanced workflows in DERIVE / ASSUME / ABDUCE