Comprehensive documentation with real-world examples
Last Updated: November 25, 2025
๐ Detailed Function Docs - Complete guides with examples
๐ง Memory Decay System - How memory fading works
๐ Status: 52 functions documented (100% coverage)
| Function | What It Does | Example |
|---|
id(n) | Get unique ID | MATCH (n) RETURN id(n) |
elementId(n) | Neo4j-compatible ID | RETURN elementId(n) |
labels(n) | Get node labels/types | RETURN labels(n) |
type(r) | Get relationship type | MATCH ()-[r]->() RETURN type(r) |
keys(n) | List property names | RETURN keys(n) |
properties(n) | Get all properties | RETURN properties(n) |
startNode(r) | Get relationship start node | RETURN startNode(r) |
endNode(r) | Get relationship end node | RETURN endNode(r) |
nodes(path) | Get nodes in path | RETURN nodes(path) |
relationships(path) | Get rels in path | RETURN relationships(path) |
exists(n.prop) | Check if property exists | WHERE exists(n.email) |
| Function | What It Does | Example |
|---|
toString(val) | Convert to string | RETURN toString(42) |
toLower(s) | Convert to lowercase | RETURN toLower("HELLO") |
toUpper(s) | Convert to UPPERCASE | RETURN toUpper("hello") |
trim(s) | Remove edge whitespace | RETURN trim(" hi ") |
ltrim(s) | Trim left side | RETURN ltrim(" hi") |
rtrim(s) | Trim right side | RETURN rtrim("hi ") |
replace(s, find, repl) | Find & replace | RETURN replace("cat", "c", "b") |
split(s, delim) | Split into list | RETURN split("a,b,c", ",") |
substring(s, start, len) | Extract substring | RETURN substring("hello", 0, 3) |
left(s, n) | First n characters | RETURN left("hello", 2) |
right(s, n) | Last n characters | RETURN right("hello", 2) |
size(s) | String/list length | RETURN size("hello") |
char_length(s) | Character count | RETURN char_length("hi") |
normalize(s) | Unicode normalization | RETURN normalize(s) |
btrim(s, chars) | Trim specific chars | RETURN btrim("!!hi!!", "!") |
| Function | What It Does | Example |
|---|
toInteger(val) | Convert to integer | RETURN toInteger("42") |
toInt(val) | Alias for toInteger | RETURN toInt("42") |
toFloat(val) | Convert to decimal | RETURN toFloat("3.14") |
toBoolean(val) | Convert to true/false | RETURN toBoolean("true") |
| Function | What It Does | Example |
|---|
abs(x) | Absolute value | RETURN abs(-5) |
ceil(x) | Round up | RETURN ceil(3.2) |
floor(x) | Round down | RETURN floor(3.8) |
round(x) | Round normally | RETURN round(3.5) |
sign(x) | Get sign (-1/0/1) | RETURN sign(-5) |
sqrt(x) | Square root | RETURN sqrt(16) |
rand() | Random 0-1 | RETURN rand() |
| Function | What It Does | Example |
|---|
sin(x) | Sine | RETURN sin(radians(90)) |
cos(x) | Cosine | RETURN cos(radians(0)) |
tan(x) | Tangent | RETURN tan(radians(45)) |
cot(x) | Cotangent | RETURN cot(radians(45)) |
asin(x) | Arc sine | RETURN asin(0.5) |
acos(x) | Arc cosine | RETURN acos(0.5) |
atan(x) | Arc tangent | RETURN atan(1) |
atan2(y, x) | 2-arg arc tangent | RETURN atan2(y, x) |
radians(deg) | Degreesโradians | RETURN radians(180) |
degrees(rad) | Radiansโdegrees | RETURN degrees(3.14) |
haversin(x) | Haversine | RETURN haversin(x) |
| Function | What It Does | Example |
|---|
exp(x) | e^x | RETURN exp(1) |
log(x) | Natural log | RETURN log(2.718) |
log10(x) | Base-10 log | RETURN log10(100) |
pi() | ฯ constant | RETURN pi() |
e() | e constant | RETURN e() |
| Function | What It Does | Example |
|---|
size(list) | List length | RETURN size([1,2,3]) |
head(list) | First element | RETURN head([1,2,3]) |
last(list) | Last element | RETURN last([1,2,3]) |
tail(list) | All except first | RETURN tail([1,2,3]) |
reverse(list) | Reverse order | RETURN reverse([1,2,3]) |
range(start, end, step) | Create number sequence | RETURN range(1, 10, 2) |
coalesce(v1, v2, ...) | First non-null value | RETURN coalesce(null, 5, 10) |
reduce(...) | Reduce list to value | See examples below |
isEmpty(x) | Check if empty | RETURN isEmpty([]) |
| Function | What It Does | Example |
|---|
vector.similarity.cosine(v1, v2) | Cosine similarity | RETURN vector.similarity.cosine([1,2,3], [2,3,4]) |
vector.similarity.euclidean(v1, v2) | Euclidean distance | RETURN vector.similarity.euclidean([0,0], [3,4]) |
Real-time signal filtering and prediction for time series data. Perfect for smoothing noisy sensor readings, tracking market sentiment, or predicting trends.
| Function | What It Does | Example |
|---|
kalman.init(config?) | Create basic filter state | RETURN kalman.init() |
kalman.process(val, state, target?) | Filter a measurement | kalman.process(23.5, s.state) |
kalman.predict(state, steps) | Predict future value | kalman.predict(s.state, 5) |
kalman.state(state) | Get current estimate | kalman.state(s.state) |
kalman.reset(state) | Reset filter | kalman.reset(s.state) |
kalman.velocity.init(pos?, vel?) | Create trend-tracking filter | kalman.velocity.init() |
kalman.velocity.process(val, state) | Filter with velocity tracking | Returns {value, velocity, state} |
kalman.velocity.predict(state, steps) | Predict with momentum | kalman.velocity.predict(s.state, 5) |
kalman.adaptive.init(config?) | Create auto-switching filter | kalman.adaptive.init() |
kalman.adaptive.process(val, state) | Filter with auto mode-switch | Returns {value, mode, state} |
| Function | What It Does | Example |
|---|
timestamp() | Current Unix timestamp (ms) | RETURN timestamp() |
datetime() | Current datetime | RETURN datetime() |
date() | Current date | RETURN date() |
time() | Current time | RETURN time() |
| Function | What It Does | Example |
|---|
isEmpty(x) | Check if empty | RETURN isEmpty("") |
isNaN(x) | Check if not-a-number | RETURN isNaN(0/0) |
nullIf(v1, v2) | Return null if equal | RETURN nullIf(5, 5) |
| Function | What It Does | Example |
|---|
count(x) | Count items | MATCH (n) RETURN count(n) |
length(path) | Path length | RETURN length(path) |
| Function | What It Does | Example |
|---|
randomUUID() | Generate UUID | RETURN randomUUID() |
rand() | Random number 0-1 | RETURN rand() |
// Find strong memories about a topic
MATCH (m:Memory)
WHERE m.content CONTAINS "database"
AND decayScore(m) > 0.6
RETURN m.title,
decayScore(m),
m.accessCount,
m.tier
ORDER BY decayScore(m) DESC
LIMIT 10
// Clean up user input
MATCH (user:User)
SET user.email = toLower(trim(user.email)),
user.name = trim(user.name)
WHERE user.email CONTAINS " " OR user.email <> toLower(user.email)
RETURN count(user) AS cleanedCount
// Find nearby locations using Pythagorean theorem
MATCH (loc1:Location), (loc2:Location)
WHERE id(loc1) < id(loc2)
WITH loc1, loc2,
sqrt(pow(loc1.x - loc2.x, 2) + pow(loc1.y - loc2.y, 2)) AS distance
WHERE distance < 10
RETURN loc1.name, loc2.name, round(distance * 100) / 100 AS distanceKm
ORDER BY distance
// Parse and normalize tags
MATCH (post:Post)
WITH post,
[tag IN split(toLower(post.tagString), ",") | trim(tag)] AS cleanTags
SET post.tags = cleanTags
RETURN count(post) AS processed
// Find memories similar to a query embedding
MATCH (m:Memory)
WHERE m.embedding IS NOT NULL
WITH m, vector.similarity.cosine(m.embedding, $queryEmbedding) AS similarity
WHERE similarity > 0.8
RETURN m.content,
similarity,
decayScore(m),
similarity * decayScore(m) AS combinedScore
ORDER BY combinedScore DESC
LIMIT 5
// Analyze decay score distribution by label
MATCH (m:KnowledgeFact)
WITH labels(m)[0] AS label,
count(m) AS total,
avg(decayScore(m)) AS avgScore,
min(decayScore(m)) AS minScore,
max(decayScore(m)) AS maxScore
RETURN label, total,
round(avgScore * 100) / 100,
round(minScore * 100) / 100,
round(maxScore * 100) / 100
// Handle missing data gracefully
MATCH (user:User)
RETURN user.name,
coalesce(user.email, user.phone, "No contact info") AS contact,
coalesce(user.age, 0) AS age
// Create pagination links
RETURN [page IN range(1, 10) |
"https://example.com/page/" + toString(page)] AS pageLinks
// Format display names
MATCH (person:Person)
WITH person,
split(person.fullName, " ") AS nameParts
RETURN person.fullName,
left(nameParts[0], 1) + ". " + last(nameParts) AS shortName,
toUpper(left(nameParts[0], 1) + left(last(nameParts), 1)) AS initials
// Haversine formula for Earth distance
MATCH (p1:Place), (p2:Place)
WITH p1, p2,
radians(p1.lat) AS lat1, radians(p1.lon) AS lon1,
radians(p2.lat) AS lat2, radians(p2.lon) AS lon2
WITH p1, p2,
haversin(lat2 - lat1) + cos(lat1) * cos(lat2) * haversin(lon2 - lon1) AS h
RETURN p1.name, p2.name,
2 * 6371 * asin(sqrt(h)) AS distanceKm
An LLM watches the Associated Press news feed in real-time, scoring each headline's market sentiment (-1.0 to +1.0). The Kalman filter smooths these noisy signals to predict stock movements.
// Step 1: Create stock trackers with Kalman filtering
UNWIND ["AAPL", "MSFT", "GOOGL", "TSLA", "NVDA"] AS symbol
CREATE (s:Stock {
symbol: symbol,
kalmanState: kalman.velocity.init(), // Track trends
sentiment: 0.0,
momentum: 0.0
})
// Step 2: LLM processes AP news headline and scores sentiment
// headline: "Apple announces record iPhone sales in China"
// $symbol = "AAPL", $sentimentScore = 0.72
// Step 3: Process the sentiment score through Kalman filter
MATCH (s:Stock {symbol: $symbol})
WITH s, kalman.velocity.process($sentimentScore, s.kalmanState) AS result
SET s.kalmanState = result.state,
s.sentiment = result.value,
s.momentum = result.velocity,
s.lastUpdate = timestamp()
RETURN s.symbol,
round(result.value * 100) / 100 AS smoothedSentiment,
round(result.velocity * 100) / 100 AS sentimentTrend,
CASE
WHEN result.velocity > 0.1 THEN "๐ BULLISH"
WHEN result.velocity < -0.1 THEN "๐ BEARISH"
ELSE "โก๏ธ NEUTRAL"
END AS signal
// Step 4: Predict sentiment 5 time-steps ahead for all stocks
MATCH (s:Stock)
WHERE s.kalmanState IS NOT NULL
RETURN s.symbol,
round(s.sentiment * 100) / 100 AS currentSentiment,
round(s.momentum * 100) / 100 AS trend,
round(kalman.velocity.predict(s.kalmanState, 5) * 100) / 100 AS predictedSentiment,
CASE
WHEN kalman.velocity.predict(s.kalmanState, 5) > s.sentiment + 0.15 THEN "๐ BUY SIGNAL"
WHEN kalman.velocity.predict(s.kalmanState, 5) < s.sentiment - 0.15 THEN "โ ๏ธ SELL SIGNAL"
ELSE "HOLD"
END AS recommendation
ORDER BY abs(s.momentum) DESC
// Step 5: Find stocks about to cross sentiment threshold
MATCH (s:Stock)
WITH s,
s.sentiment AS current,
kalman.velocity.predict(s.kalmanState, 3) AS predicted
WHERE current < 0.7 AND predicted >= 0.7 // About to go strongly bullish
RETURN s.symbol, current, predicted, "๐ฏ BREAKOUT CANDIDATE" AS alert
// Initialize temperature sensors with Kalman filtering
CREATE (s:Sensor {
id: "greenhouse-temp-1",
location: "Zone A",
kalmanState: kalman.init({measurementNoise: 50.0})
})
// Process incoming temperature reading and smooth it
MATCH (s:Sensor {id: $sensorId})
WITH s, kalman.process($rawTemperature, s.kalmanState, 25.0) AS result
SET s.kalmanState = result.state,
s.temperature = result.value,
s.lastReading = timestamp()
RETURN s.id,
$rawTemperature AS raw,
round(result.value * 10) / 10 AS smoothed
// Alert on predicted overheating (predict 10 readings ahead)
MATCH (s:Sensor)
WHERE kalman.predict(s.kalmanState, 10) > 35.0
RETURN s.id, s.location,
round(kalman.predict(s.kalmanState, 10) * 10) / 10 AS predictedTemp,
"โ ๏ธ Predicted overheat in ~10 readings" AS alert
// Use adaptive filter for crypto (high volatility) - auto-switches modes
CREATE (c:Crypto {
symbol: "BTC",
kalmanState: kalman.adaptive.init({
trendThreshold: 0.05, // Switch to velocity mode on 5% trend
hysteresis: 5 // Quick adaptation
})
})
// Process price data - filter auto-switches between smoothing and tracking
MATCH (c:Crypto {symbol: $symbol})
WITH c, kalman.adaptive.process($price, c.kalmanState) AS result
SET c.kalmanState = result.state,
c.price = result.value,
c.filterMode = result.mode
RETURN c.symbol,
round(result.value) AS filteredPrice,
result.mode AS currentMode,
CASE result.mode
WHEN "velocity" THEN "๐ Trending market - tracking momentum"
ELSE "๐ Stable market - smoothing noise"
END AS interpretation
id(), labels(), type(), keys(), properties()
trim(), toLower(), toUpper(), replace(), split()
toInteger(), toFloat(), toString(), toBoolean()
count(), avg(), sum(), min(), max()
abs(), ceil(), floor(), round(), sqrt(), pow()
sin(), cos(), haversin(), atan2(), sqrt() (for distances)
vector.similarity.cosine(), vector.similarity.euclidean()
kalman.init(), kalman.process(), kalman.predict()
kalman.velocity.init(), kalman.velocity.process(), kalman.velocity.predict()
kalman.adaptive.init(), kalman.adaptive.process()
id(), labels(), type()
toString(), toInteger(), toFloat()
toLower(), toUpper()
trim(), replace(), split()
abs(), ceil(), floor(), round()
sin(), cos(), tan() and other trig functions
sqrt(), exp(), log()
vector.similarity.*() - depends on vector size
- Cache computed values instead of recalculating
- Use indexes for WHERE clauses before function calls
- Batch operations instead of per-node function calls
- Pre-compute expensive math when possible
MATCH (n)
WHERE toLower(n.name) = toLower($searchTerm)
RETURN n
MATCH (n)
RETURN coalesce(n.optionalProperty, "default value") AS prop
MATCH (n:RawData)
WITH n, split(n.csvLine, ",") AS fields
CREATE (p:ParsedData {
field1: trim(fields[0]),
field2: toInteger(trim(fields[1])),
field3: toFloat(trim(fields[2]))
})
MATCH (person:Person)
RETURN person.name,
floor((timestamp() - person.birthTimestamp) / (365.25 * 24 * 60 * 60 * 1000)) AS age
MATCH (doc:Document)
WHERE doc.embedding IS NOT NULL
WITH doc, vector.similarity.cosine(doc.embedding, $queryVector) AS score
WHERE score > 0.75
RETURN doc.title, score
ORDER BY score DESC
LIMIT 10
When the procedure is called against a database whose NORNICDB_SEARCH_VECTOR_ENABLED is false (per-DB or global, with the per-DB override winning):
To switch behaviour, flip the master switch via:
curl -X PUT http://localhost:7474/admin/databases/<db>/config \
-H "Content-Type: application/json" \
-d '{"overrides": {"NORNICDB_SEARCH_VECTOR_ENABLED": "true"}}'
See Per-Database Search Index Flags.
- Atkinson-Shiffrin Model (1968) - Three-store memory model
- Ebbinghaus Forgetting Curve (1885) - Exponential memory decay
- Spaced Repetition - Optimal review timing for retention
- Khan Academy - Trigonometry basics
- 3Blue1Brown - Visual math explanations (YouTube)
- Essence of Calculus - Understanding exponentials and logs
- Official Neo4j Cypher manual
- Neo4j function reference
Documentation Status: โ
Complete
Functions Documented: 62/62 (100%)
Examples Provided: 160+
Last Updated: November 29, 2025