Cypher Functions¶
QilbeeDB supports a wide range of built-in functions for data manipulation and analysis.
String Functions¶
toLower / toUpper¶
trim / lTrim / rTrim¶
RETURN trim(" hello ") AS trimmed // "hello"
RETURN lTrim(" hello ") AS leftTrim // "hello "
RETURN rTrim(" hello ") AS rightTrim // " hello"
substring¶
RETURN substring("hello world", 0, 5) AS sub // "hello"
RETURN substring("hello world", 6) AS sub // "world"
replace¶
split¶
size (String Length)¶
String Concatenation¶
Numeric Functions¶
abs¶
round / floor / ceil¶
sqrt / power¶
sign¶
rand¶
Aggregation Functions¶
count¶
MATCH (u:User)
RETURN count(u) AS totalUsers
// Count distinct
MATCH (u:User)
RETURN count(DISTINCT u.city) AS cities
sum¶
avg¶
min / max¶
collect¶
percentile¶
MATCH (u:User)
RETURN percentileDisc(u.age, 0.5) AS medianAge
RETURN percentileCont(u.age, 0.95) AS p95Age
List Functions¶
size (List Length)¶
head / last¶
tail¶
range¶
RETURN range(1, 10) AS numbers // [1, 2, 3, ..., 10]
RETURN range(1, 10, 2) AS evens // [1, 3, 5, 7, 9]
reverse¶
List Comprehension¶
Date/Time Functions¶
datetime¶
date¶
time¶
duration¶
RETURN duration("P1Y2M3D") AS period // 1 year, 2 months, 3 days
RETURN duration("PT1H30M") AS timespan // 1 hour, 30 minutes
Date Arithmetic¶
Extract Components¶
Type Conversion Functions¶
toInteger¶
toFloat¶
toString¶
toBoolean¶
Predicate Functions¶
exists¶
coalesce¶
CASE¶
MATCH (u:User)
RETURN u.name,
CASE
WHEN u.age < 18 THEN "Minor"
WHEN u.age < 65 THEN "Adult"
ELSE "Senior"
END AS ageGroup
Path Functions¶
length (Path Length)¶
nodes¶
relationships¶
shortestPath¶
MATCH path = shortestPath((a:User {name: 'Alice'})-[:KNOWS*]-(b:User {name: 'Bob'}))
RETURN length(path) AS distance
Node/Relationship Functions¶
id¶
labels¶
type (Relationship Type)¶
properties¶
keys¶
Spatial Functions (if supported)¶
point¶
distance¶
WITH point({latitude: 37.7749, longitude: -122.4194}) AS sf,
point({latitude: 40.7128, longitude: -74.0060}) AS nyc
RETURN distance(sf, nyc) AS distanceMeters
User-Defined Functions¶
randomUUID¶
Common Function Combinations¶
Full Name¶
Email Normalization¶
Age from Birthday¶
Default Values¶
Time Ago¶
MATCH (p:Post)
WITH p, duration.between(p.created, datetime()) AS elapsed
RETURN p.title,
CASE
WHEN elapsed.days = 0 THEN "Today"
WHEN elapsed.days = 1 THEN "Yesterday"
WHEN elapsed.days < 7 THEN elapsed.days + " days ago"
WHEN elapsed.days < 30 THEN (elapsed.days / 7) + " weeks ago"
ELSE (elapsed.days / 30) + " months ago"
END AS timeAgo
Search Score¶
MATCH (p:Post)
WHERE toLower(p.title) CONTAINS toLower($query)
OR toLower(p.content) CONTAINS toLower($query)
RETURN p,
(CASE WHEN toLower(p.title) CONTAINS toLower($query) THEN 10 ELSE 0 END +
CASE WHEN toLower(p.content) CONTAINS toLower($query) THEN 5 ELSE 0 END +
p.likes * 0.1) AS score
ORDER BY score DESC
Performance Tips¶
-
Use Functions on Indexed Properties Carefully
-
Aggregate Early
-
Use coalesce for Defaults
Next Steps¶
- Learn MATCH clause
- Explore WHERE filtering
- Use RETURN clause
- Read Cypher Introduction