Metadata Filters and Tenant Isolation
Metadata filters constrain retrieval by tenant, group, publication status, language, date, and source type. Derive filters from authenticated server-side context; do not allow a model or untrusted query parameter to broaden access. Test how the chosen store applies filters, especially with approximate and hybrid search.
Use namespaces, partitions, row-level policies, separate indexes, or dedicated deployments according to threat model. A post-retrieval filter may be too late if unauthorized text has already reached intermediate systems.
Implementation example
function buildFilter(auth) {
if (!auth?.tenantId) throw new Error("Missing tenant");
return {tenantId:auth.tenantId,status:"published",deleted:false};
}💡 The filter must be enforced before unauthorized text enters model context.
Key Takeaways
- Inspect the relevant pipeline stage instead of guessing.
- Preserve source provenance, versions, and access scope.
- Measure quality on representative queries.
Knowledge Check
Where should tenant scope originate?