Cypher Overview

LatticeDB uses the Cypher query language for graph operations. Cypher is a declarative language where you describe patterns to match and operations to perform, rather than specifying how to execute them.

Syntax at a Glance

Nodes are written in parentheses, edges in square brackets:

-- Match a pattern
MATCH (person:Person)-[:KNOWS]->(friend:Person)
WHERE person.name = "Alice"
RETURN friend.name

Supported Clauses

ClausePurpose
MATCHFind patterns in the graph
WHEREFilter results with conditions
RETURNSpecify output columns
CREATECreate nodes and edges
SETUpdate properties and labels
DELETERemove nodes and edges
REMOVERemove properties and labels
MERGEMatch or create a pattern
WITHChain query parts, pipe results
UNWINDExpand lists into rows
ORDER BYSort results
LIMITLimit number of results
SKIPSkip first N results

LatticeDB Extensions

LatticeDB extends Cypher with two operators for search:

Vector Distance (<=>)

Find nodes with similar embeddings:

MATCH (chunk:Chunk)
WHERE chunk.embedding <=> $query_vector < 0.5
RETURN chunk.text
ORDER BY chunk.embedding <=> $query_vector

See Vector Search for details.

Full-Text Search (@@)

Search indexed text content:

MATCH (doc:Document)
WHERE doc.content @@ "neural networks"
RETURN doc.title

See Full-Text Search for details.

Expressions

Operators

CategoryOperators
Comparison=, <>, <, <=, >, >=
LogicalAND, OR, NOT, XOR
Arithmetic+, -, *, /, %, ^
StringCONTAINS, STARTS WITH, ENDS WITH
NullIS NULL, IS NOT NULL
Search<=> (vector distance), @@ (full-text)

Functions

FunctionDescription
id(node)Get node ID
coalesce(a, b, ...)Return first non-null value
abs(x)Absolute value
size(list)List length
toInteger(x)Convert to integer
toFloat(x)Convert to float

See Functions for details.

Aggregations

FunctionDescription
count(x)Count values
sum(x)Sum values
avg(x)Average values
min(x)Minimum value
max(x)Maximum value
collect(x)Collect into list

See Aggregations for details.

Parameters

Use $name syntax to pass values safely:

MATCH (n:Person) WHERE n.name = $name RETURN n

See Parameters for language-specific binding.