Short answer: metadata filters restrict vector search to records a tenant and user are allowed to retrieve, then narrow those records to the operational context of the question. For an internal logistics knowledge-base bot, the least complex sound design is one shared index with mandatory tenantId filtering, plus optional filters such as region, document status, and effective date. Similarity decides what is relevant only inside that eligible set.
| Choice | Isolation model | Operational burden | Best fit |
|---|---|---|---|
| Shared index, mandatory filter | Every chunk carries tenantId; every query supplies it | Lowest | Many small tenants with the same schema |
| Index per tenant | Storage boundary separates tenants | Higher | A few large tenants or contractual isolation requirements |
| Shared index without a tenant filter | No retrieval boundary | Low on paper, unacceptable in practice | Never for tenant-private documents |
Recommendation: start with the shared index and make the tenant predicate impossible for application code to omit. Move a tenant to a dedicated index only when an isolation requirement or workload characteristic justifies the extra deployment work. The filter is an authorization boundary first and a relevance tool second.
What do metadata filters do in multi-tenant vector search?
A vector represents semantic similarity. It does not represent permission. Two carriers may use nearly identical language for detention rules, damaged freight, or proof-of-delivery procedures. Their chunks can therefore sit close together in vector space even though one carrier must never see the other's handbook.
Metadata is structured data stored beside each chunk. In this scenario, a record might carry tenantId, documentId, region, status, effectiveFrom, and effectiveTo. A filter compares those fields with exact values or ranges before the application accepts the search results. Conceptually, the query is: find the nearest chunks among records where tenantId equals the authenticated tenant, the document is published, and its validity window covers the shipment date.
That last distinction matters. The embedding answers, "Which text resembles this question?" The metadata predicate answers, "Which text is eligible to answer it?" Those are separate jobs.
Fail closed.
The two criteria that matter most
The first criterion is whether the tenant constraint can be omitted. Passing an arbitrary filter object from a request handler is convenient, but convenience is the wrong optimization at an authorization boundary. Tenant identity should come from the verified session or service context, never from a tenant ID supplied in the question body. A repository-level search function can require that context and construct the mandatory predicate itself.
The second criterion is whether every returned claim can be traced to the exact eligible source. Retrieval-augmented generation combines retrieved material with generation; the original RAG paper describes this split between parametric and non-parametric memory. In a help-center bot, keep the chunk's document ID, revision, section, and stable source URL with the text. The answer layer should cite only chunks that survived the same filter used for retrieval. Do not run a broad search and attempt to redact foreign-tenant hits afterward.
Filters also shape recall. A typo in region, an unpublished status left on a valid manual, or an incorrect effective date can hide the best evidence. That failure looks like a weak embedding model, but changing models will not repair excluded data. I would spend an hour testing predicate construction before spending a day tuning chunk size. For a solo SaaS, that is a better revenue-per-hour trade.
Consider a shipment dated March 10. The current carrier guide is tagged effectiveFrom: March 11, while the prior guide was accidentally marked archived during ingestion. The tenant predicate is correct, the nearest-neighbor search is healthy, and the generator receives no evidence. Relaxing the filter until something appears would be the dangerous fix: it could admit a future rule or an obsolete one and still produce a fluent answer. The useful diagnostic is a trace showing that both candidate documents were excluded, with the metadata fields that caused each exclusion. Then the system can return no answer and the operator can repair publication state. This is why filter observability belongs beside relevance evaluation, not buried in storage metrics.
No evidence means no answer.
A narrow TypeScript boundary
The useful abstraction is small. Application code supplies the question and trusted access context. The retrieval adapter owns filter construction, and its return type preserves citation fields.
interface AccessContext { tenantId: string; region?: string; } interface SearchHit { text: string; score: number; citation: { documentId: string; revision: number; section: string; sourceUrl: string; }; } interface VectorStore { search(input: { vector: number[]; limit: number; filter: Record<string, unknown>; }): Promise<SearchHit[]>; } async function retrieveLogisticsGuidance( store: VectorStore, questionVector: number[], access: AccessContext, shipmentDate: string ): Promise<SearchHit[]> { const filter: Record<string, unknown> = { tenantId: { eq: access.tenantId }, status: { eq: "published" }, effectiveFrom: { lte: shipmentDate }, effectiveTo: { gt: shipmentDate } }; if (access.region) { filter.region = { in: [access.region, "global"] }; } return store.search({ vector: questionVector, limit: 8, filter }); } The operator spelling varies across implementations, so the adapter is intentionally generic. Its invariant does not vary: tenantId is created from AccessContext inside the function. A caller cannot replace it with input copied from an HTTP payload.
Ingestion needs the matching discipline. Reject a chunk that lacks a tenant ID, document ID, revision, status, or citation target. Normalize enumerated fields such as region before indexing. When a manual is superseded, publish the new revision and change the old revision's status as one controlled operation. The exact transaction mechanism depends on the storage system, but readers should never receive a mixture that the application considers current.
Test the boundary, not just answer quality
A polished answer can still be a data leak. Evaluation therefore needs adversarial retrieval cases alongside ordinary relevance checks. Create two synthetic tenants with near-duplicate wording, ask each tenant the same operational question, and assert that every returned hit has the expected tenantId. Repeat the test with no region, an unknown region, boundary dates, unpublished revisions, and an empty result set.
Keep the test direct. Assert on retrieval records before generation, because a model may paraphrase away the evidence that reveals a bad hit. Then verify that every citation in the generated answer maps to one of those records. Zero eligible hits should produce a clear lack-of-evidence response, not an ungrounded completion.
Observability should follow the same boundary. Log a request ID, a one-way tenant identifier suitable for operations, filter keys, result counts, document revisions, and latency. Avoid logging raw questions or chunk text by default; logistics documents can contain customer names, addresses, and shipment details. Watch the rate of zero-result queries after metadata migrations. A sudden jump often points to a schema or normalization error rather than a change in user intent.
Ship this in stages: predicate tests, retrieval-only shadow checks, then answers with citations. Weekly shipping is still possible when the retrieval contract is narrow. The differentiated work is the logistics content and feedback loop; index operations and embedding plumbing are good candidates to outsource behind stable interfaces.
When is a dedicated index the better choice?
A per-tenant index is the runner-up when a contract requires a separate storage boundary, when one large tenant needs independent retention or backup operations, or when its workload would distort the shared index. It also makes the top-level tenant boundary easier to inspect. The cost is operational multiplication: provisioning, migrations, monitoring, and capacity handling now repeat per tenant.
The shared-index recommendation has a real limitation: its isolation guarantee depends on every read path enforcing the same mandatory predicate. It is not suitable when policy requires physical data separation, tenant-specific encryption ownership, or independently controlled deletion and backup. In those cases, choose dedicated storage even if it slows weekly shipping. Conversely, a dedicated index is a poor default for hundreds of small tenants because routine schema changes and monitoring fan out across every partition. There is no universal winner; the boundary requirement decides.
Dedicated indexes do not eliminate metadata filters. The logistics bot still needs to select published documents, the right region, and the revision effective on a shipment date. Physical separation handles one boundary; structured predicates handle the rest.
For most small help-center tenants, start shared, enforce tenant identity in one trusted retrieval layer, and test it as an authorization control. Keep citations attached throughout the pipeline. That combination grounds answers without turning each new customer into an infrastructure project.