Skip to content

Ontologies: Facts a Similarity Search Can't Find

Learning objectives

By the end of this module you should be able to:

  • Explain why vector similarity retrieval has a structural blind spot for relationship questions, and why that blind spot isn't fixable by a better embedding model.
  • Argue for reusing an existing datastore's native capability over introducing a new one, and recognize when that argument doesn't hold.
  • Extend the tenant isolation principle to multi-hop graph traversal, where the naive version of the guarantee quietly breaks.

The question similarity search can't answer

A retrieval-augmented system built on vector search answers one shape of question well: "find me text that reads like this." Ask it something whose answer depends on a relationship rather than a resemblance — "which companies has Project X worked with," "who signed contract Y" — and the architecture doesn't fail loudly. It fails quietly, by retrieving chunks that merely mention the right words and hoping synthesis stitches the relationship back together from fragments that were never guaranteed to land in the same context window.

This isn't a tuning problem. A better embedding model narrows the gap between "reads like this" and "means this," but a fact like "Acme signed with Beta" isn't a resemblance at all — it's a discrete assertion connecting two named things. No amount of embedding-space nearness turns a paragraph into a queryable edge between two nodes. The fix isn't a smarter chunk; it's a second retrieval mode built for a fundamentally different question shape, running alongside similarity search rather than replacing it. Most of what a corpus is asked stays a similarity question. A minority of questions are relationship questions, and that minority needs a structure similarity search was never built to provide.

Extraction as a second, structural pass over the same text

The fix that generalizes is to extract entities and relationships from a document once, at ingestion time, as a discrete structured pass alongside the chunk-and-embed pipeline every document already goes through — not instead of it. A named-entity/relationship extraction step reads a document's full text (deliberately before it gets split into fixed-size chunks, since a relationship stated across two sentences can straddle a chunk boundary and become unrecoverable from either fragment alone), and writes out a small set of typed facts: this name is an organization, that name is a person, and a relationship connects them, with a snippet supporting the claim for citation.

Those facts get stored, and a second retrieval path — separate from vector search, running in parallel — can now answer the relationship shape of question directly: not "chunks that mention Acme," but "everything Acme is asserted to be connected to." The chat pipeline runs both paths on every turn and merges what each finds; a query that only needed similarity search gets nothing extra from the graph path (it costs one cheap, empty lookup), and a query that needed the relationship gets an answer grounded in an explicit assertion instead of a hopeful re-assembly of nearby text.

Reuse the datastore you already trust

Once you decide to store extracted facts as a graph — nodes for entities, edges for relationships — the obvious next question is what stores a graph. The reflexive answer is a dedicated graph database. The better first question is whether the datastore you already run, already trust, and already have a tenant-isolation story for can do the job.

A document store with a recursive-traversal aggregation stage can, in fact, walk a graph: seed on a starting node, follow edges outward to a bounded depth, and return everything reachable. It isn't marketed as a graph database, but the operation it performs — bounded recursive traversal from a seed — is exactly the operation a relationship query needs. Reaching for a dedicated graph engine before confirming the document store can't do it isn't caution; it's an unexamined default. Every new datastore is a new thing to operate, secure, back up, and reason about under multi-tenancy — a cost that's easy to under-count when the new tool is shiny and the existing one is merely familiar.

This is the same discipline argued in Document Ingestion Router about a different substrate choice: study what a new tool would buy you, then check rigorously whether something already in the stack buys the same thing at zero incremental operational cost. Sometimes the answer really is "no, you need the specialized tool" — a graph workload with genuinely deep traversal depths, or graph-specific query ergonomics an aggregation pipeline can't express reasonably, would tip the other way. The discipline isn't "never adopt a new datastore." It's "don't adopt one on reflex, before the existing one has been asked the question directly."

The hop that breaks an unexamined isolation guarantee

Reusing the trusted datastore doesn't mean the isolation guarantee it already gave you for ordinary queries survives graph traversal unexamined. This is the sharpest new idea in the whole design, and it's worth sitting with.

Tenant isolation as usually implemented answers one question well: does this query, matched against this filter, stay inside the caller's tenant and clearance? A single-hop query asks that question once. A multi-hop graph traversal — follow this node's edges, then follow those nodes' edges, to some bounded depth — asks it once per hop, and a naive implementation checks it only at the first one. Get that wrong and a caller can walk: reach a node they're permitted to see directly, follow an edge from that node into a second node they were never permitted to reach on their own, and the traversal happily returns it, because the isolation check that gated the seed never re-ran at the second hop. The tenant boundary held at hop one and quietly evaporated at hop two.

The only correct version re-asserts tenant and clearance at every hop, not just the entry point — the traversal's own filter has to re-apply the full isolation predicate at each step outward, so a permitted node can never become a bridge into data that wouldn't have been reachable directly. This is zero-trust for AI's core claim, applied somewhere it isn't obvious it needs applying: a security boundary that's airtight at a query's entry point but unexamined at its second internal step is a boundary with an undiscovered gap, not a boundary that holds. Multi-hop traversal is exactly the kind of feature that quietly introduces a second step nobody thought to re-check — which is the general shape of where zero-trust guarantees actually get lost in real systems.

Key takeaways

  • Relationship questions are a different question shape than similarity questions, not a harder version of the same one — no embedding improvement closes that gap, because the underlying fact isn't a resemblance to begin with.
  • Ask the existing datastore before adopting a new one. A capability that looks like it demands a specialized tool sometimes already lives, underused, inside a datastore you already operate and already trust — and every new datastore carries a real, easy-to-under-count operational cost.
  • A traversal is only as isolated as its least-checked hop. Re-asserting tenant and clearance once at the seed is not the same guarantee as re-asserting it at every step outward — the difference is exactly the gap an attacker walks through.

For further study

  1. The module argues a better embedding model can't close the gap between "reads like this" and "means this." Construct the strongest counter- argument you can for why sufficiently good embeddings might eventually subsume relationship extraction, and then identify the specific place your counter-argument breaks down.
  2. "Don't adopt a new datastore on reflex" is a discipline, not an absolute rule. Describe a concrete graph workload where a dedicated graph engine would be the right call even after the existing datastore was asked the question directly, and explain what tipped it.
  3. Design a test you could run against a multi-hop traversal implementation to prove it re-checks isolation at every hop rather than only the seed — not by reading the code, but by constructing data and a query that would return a wrong answer if the check were missing at any single hop.

Next: Retrieval That Checks Its Own Work — reranking, a bounded adaptive retrieval loop, and verifying an answer's own citations, staying on the retrieval-and-reasoning thread this module opened.