06 · HYBRID — VECTOR + GRAPH
Semantic entry, then graph expansion
Use similarity to find the entry point; use the graph to traverse, explain, and re-rank. The question ≈ "deep learning spanning ML and NLP", encoded as a query vector.
vector + traversal
vector store: step 1 only
1 VECTOR — what is the question about?
read_neo4j_cypher→ warehouse
MATCH (t:Topic)
RETURN t.name AS topic, round(1 - cosineDistance(t.embedding, $q), 4) AS similarity
ORDER BY similarity DESC LIMIT 3
3 rows
The two AI topics surface; unrelated topics sit at ~0. A vector store stops here.
2 GRAPH — how does that topic connect, by name?
MATCH path = (start:Topic {name:'Machine Learning'})-[:RELATED_TO*1..2]->(t2:Topic)
RETURN [n IN nodes(path) | n.name] AS topic_chain, length(path) AS hops
3 rows · path readout
#1079
Machine Learning→Natural Language Processing→Computer Vision
[n IN nodes(path) | n.name] reads the neighborhood back in traversal order — similarity search cannot represent this.
3 HYBRID — re-rank the grounded neighborhood
MATCH (t:Topic)-[:DISCUSSES]->(d:Document)
WHERE t.name IN ['Machine Learning','Natural Language Processing','Computer Vision']
RETURN d.title AS document, round(1 - cosineDistance(d.embedding, $q), 4) AS similarity
ORDER BY similarity DESC LIMIT 5
top 3 of 5
The graph scopes the candidates; the vector re-ranks them. The two foundational ML/NLP papers rise; the off-topic CV paper sinks. Relevant and explainable.
4 ALL AT ONCE — the whole loop in one statement
MATCH (ml:Topic {name:'Machine Learning'})-[:RELATED_TO*1..2]->(t2:Topic)-[:DISCUSSES]->(d:Document)
RETURN DISTINCT d.title AS document, t2.name AS via_topic,
round(1 - cosineDistance(d.embedding, $q), 4) AS similarity
ORDER BY similarity DESC
3 rows · unblocked by
#1083
Variable-length graph expansion feeds a vector re-rank in one Cypher statement — no client round-trip between traversal and ranking. The NLP-adjacent paper rises; the CV paper sinks.
ClickHouse-native vectors.
cosineDistance /
L2Distance /
gds.similarity.* and
CALL db.index.vector.queryNodes(…) run on the ClickGraph/ClickHouse endpoint.
Variable-length expansion feeds the chained
DISCUSSES hop directly — no
WITH barrier — which composes once the anonymous-alias collision
(
#1083, fixing
#1081) is in place.
One naming caveat: the path start node is
ml, not
t — a
variable-length-path endpoint named exactly
t collides with ClickGraph's
reserved internal VLP-CTE alias and is rejected with an actionable error
(
#1085); any other name
resolves correctly.