Built-in Functions in LoraDB
Function names are case-insensitive; canonical camelCase is
shown on each page. Unknown names and wrong arity are rejected at
analysis time (Unknown function 'foo', WrongArity).
Most functions propagate null — any null argument makes the
result null. The exceptions are the aggregates, coalesce,
timestamp, pi, e, and rand.
Categories
| Category | Examples | Reference |
|---|---|---|
| Aggregation | count, sum, collect, percentileCont | Aggregation |
| String | toLower, split, substring, replace | String |
| Math | abs, sqrt, sin, log, rand | Math |
| List | size, head, range, reduce | List |
| Temporal | date, datetime, duration.between | Temporal |
| Spatial | point, distance | Spatial |
| Vector | vector, vector.similarity.cosine, vector.similarity.euclidean, vector_distance, vector_norm, vector_dimension_count, toIntegerList, toFloatList | Vector |
| Path | length, nodes, relationships | Paths |
Entity introspection
| Function | Takes | Returns |
|---|---|---|
id(x) | node | relationship | Int — internal id |
labels(n) | node | List<String> |
type(r) | relationship | String — rel type |
keys(x) | node | rel | map | List<String> |
properties(x) | node | rel | map | Map |
MATCH (u:User)-[r:FOLLOWS]->(v:User)
RETURN id(u), labels(u), type(r), keys(u), properties(u)
Common uses
// Dump every property on a node as a map
MATCH (u:User {id: $id}) RETURN properties(u)
// Discover which labels a node carries
MATCH (n) WHERE id(n) = $raw_id RETURN labels(n)
// Inspect the type of a matched edge
MATCH (a)-[r]->(b) RETURN type(r), count(*) ORDER BY count(*) DESC
// Avoid duplicate pair rows
MATCH (a)-[:KNOWS]-(b) WHERE id(a) < id(b) RETURN a, b
See Graph model → Identity for
why id() is opaque.
Type conversion and checking
| Function | Behaviour |
|---|---|
toString(x) | any → String; null → null |
toInteger(x) / toInt(x) | Int/Float/String/Bool → Int or null |
toFloat(x) | Int/Float/String → Float or null |
toBoolean(x) / toBooleanOrNull(x) | Bool/String/Int → Bool or null |
valueType(x) | name of the value's type, e.g. "INTEGER", "LIST<T>" |
coalesce(a, b, …) | first non-null argument |
timestamp() | current Unix time in milliseconds |
RETURN toInteger('42'), -- 42
toInteger('abc'), -- null
toFloat(42), -- 42.0
coalesce(null, null, 'fallback'), -- 'fallback'
valueType(1), -- 'INTEGER'
valueType([1, 2, 3]), -- 'LIST<INTEGER>'
valueType(date('2024-01-15')) -- 'DATE'
coalesce recipes
// Default a missing property
MATCH (p:Person) RETURN p.name, coalesce(p.nickname, p.name) AS display
// Cascade through several optional fields
RETURN coalesce($phone, $email, 'unknown') AS contact
// Replace null in ordering
MATCH (p:Person)
RETURN p.name, coalesce(p.rank, 999999) AS rank_for_sort
ORDER BY rank_for_sort
For multi-branch logic with arbitrary predicates per branch (not just
"first non-null"), use CASE.
valueType recipes
// Filter a heterogeneous list to numbers only
MATCH (n)
WHERE all(x IN n.values WHERE valueType(x) = 'INTEGER')
RETURN n
// Group by runtime type
UNWIND [1, 'two', 3.0, true, null] AS x
RETURN valueType(x) AS t, count(*) AS n
ORDER BY t
timestamp
Wall-clock milliseconds since the Unix epoch.
MERGE (c:Counter {name: 'events'})
ON CREATE SET c.first_seen = timestamp()
SET c.last_seen = timestamp()
See Data Types for every valueType return
value and for how each type maps between LoraDB and host languages.
Null propagation — the common thread
Most functions return null when any argument is null. A small
handful don't, so they're worth memorising:
- Aggregates (
count,sum, …) skip null inputs (exceptcount(*), which counts rows). coalesce(a, b, …)— returns the first non-null argument.timestamp(),pi(),e(),rand()— take no arguments.
Everywhere else, expect null in → null out. This is what makes
IS NULL / IS NOT NULL essential over
= null.
Quick lookup
Finding the right function for a task:
| I want to… | Reach for |
|---|---|
| Pick the first non-null value | coalesce(a, b, …) |
| Branch on arbitrary conditions | CASE WHEN … THEN … END |
| Count rows matching a condition | count(CASE WHEN … THEN 1 END) |
| Concatenate a list into a string | reduce over split / collect |
| Current time (ms) | timestamp() |
| Current calendar day | date() |
| Name of a value's type | valueType(x) |
| Internal id of a node / rel | id(x) |
| Total order over temporal values | <, <=, >, >= — see Ordering |
| Cartesian or geodesic distance | distance(a, b) |
| Score a VECTOR against a query vector | vector.similarity.cosine(v, $q) |
| Signed distance under a metric | vector_distance(a, b, EUCLIDEAN) |
| Magnitude of a VECTOR | vector_norm(v, EUCLIDEAN) |
| Dimension of a VECTOR | vector_dimension_count(v) or size(v) |
| Convert VECTOR coordinates back to a LIST | toIntegerList(v) / toFloatList(v) |
Not supported
- APOC-style utilities (
apoc.*) — no compatibility layer. - Procedures (
CALL db.labels()etc.) — rejected at analysis time. - User-defined functions — no registration surface.
Full list in Limitations.
See also
- Aggregation Functions —
count,collect, percentiles. - String, Math, List — everyday helpers.
- Temporal, Spatial — typed domains.
- Data Types Overview — value shapes.
- Queries → Parameters — binding typed values from the host.