Graph and Cypher · Engineering
Vector + graph recommendation queries
How vector similarity, graph proximity, and deterministic scoring combine for recommendations without a separate service.
Recommendation features often start with “find similar items” and quickly become “find similar items that are also connected to this user’s history”. Vector search alone returns semantically close things; graph proximity alone returns related things. Combining them is more useful than either.
NonoDB has two ways to combine the signals: hybrid_search for vector-seeded graph reranking, and traverse with a vector seed for graph expansion.
Hybrid search
{"op":"hybrid_search", "coll":"nodes", "field":"embedding", "vector":[0.1,0.9,0.0], "k":10, "filter":{}, "direction":"out", "max_depth":2, "limit":20, "vector_weight":0.7, "graph_weight":0.3, "projection":{"name":1}}The operation:
- takes the top-K vector hits as seeds;
- expands the graph neighborhood up to
max_depth; - computes a vector score for each candidate;
- computes a graph score from proximity;
- normalizes and combines them with the configured weights;
- sorts by score descending, with
_idtie-breaking.
Each result includes vector_score, graph_score, and the final score.
Vector scores are mapped into [0,1] according to the index metric: cosine similarity mapped to [0,1], a logistic transform of the dot product, or 1/(1+squared_l2_distance). The graph score is 1/(1+depth).
Deterministic tie-breaking matters. A recommendation feed that changes order between identical requests is hard to debug and looks unstable to users.
Why graph reranking helps
Consider a product catalog. A vector search for “running shoes” may return shoes that are visually and semantically similar, but not in stock, not in the user’s size, or not compatible with the current promotion.
Graph edges can encode “same category”, “bought together”, “compatible with”, or “replacement for”. A vector candidate near a connected node gets a higher graph score. The result is still similarity-driven, but relationship-aware.
This is not a learned recommender. It is a transparent scoring function with weights you can tune and explain.
Vector seed traversal
traverse can start from vector results instead of explicit node ids:
{"op":"traverse", "coll":"nodes", "seed":{"vector":{ "field":"embedding", "vector":[0.1,0.9,0.0], "k":5, "filter":{} }}, "max_depth":2}start and seed are mutually exclusive. The vector index must exist, and the query must have the indexed dimensions. Results become start ids in vector order; k is limited to 1–1,000.
Use this when you want the graph shape, not a flat reranked list: “show me the two-hop neighborhood around the five most similar items”.
Filters and temporal edges
edge_filter, node_filter, labels, and as_of apply during expansion. That makes it possible to recommend only currently valid relationships, only active nodes, or only edges with a minimum weight.
Filters are applied before scoring and before the final limit. A highly selective filter can reduce the candidate set dramatically; a filter with no index may force more scanning.
Limits
- vector seed
k: 1–1,000; max_depth: 0–64;limit: final result cap;- graph traversal node/edge/byte budgets apply;
- one graph definition per node collection;
- graph reads require scopes on both node and edge collections;
- vault collections are rejected.
The result is bounded. A recommendation query cannot silently walk the entire graph.
When to use what
Use search_all hybrid when:
- you want one ranked list from lexical and vector signals;
- graph structure is not part of the ranking;
- the application can merge results itself.
Use hybrid_search when:
- vector similarity is the seed;
- relationships should change the order;
- you want deterministic, explainable scores.
Use traverse with a seed when:
- the graph shape matters more than a flat ranking;
- you need to display paths, neighborhoods, or explanations.
What it is not
- No learned embeddings or model serving.
- No collaborative filtering.
- No online learning.
- No distributed graph.
- No guarantee that weights generalize across datasets.
The weights are application policy. Start with a lexical or vector baseline, add graph signal, and measure whether it improves the outcome.
The graph guide and search guide document the response fields and limits.