1:1 mentoring with Big Tech AI engineers
RAG & MCP

Metadata & Filters

Design the metadata each chunk carries, put permissions and time in the store's query on every path, predict how many results a filter leaves, and let a model fill a schema without letting it set trusted fields.

Last updated

Production11 min readFirst readVector Indexes & StoresChunking Strategies

After this section you can

  • Sort a chunk’s metadata into filter, boost and carry fields, and say who may set each one
  • Predict how many rows a filter leaves in your store, and choose how it should run and what to index
  • Show that one user cannot retrieve another’s documents, on every path, with a test that tries to break it
06

Metadata & Filters: Who May Retrieve What

The index can be searched. Now decide who may retrieve what, and show that the rule holds.

Key idea

A filter decides which chunks may be ranked at all; similarity only orders what it lets through. Build the hard filters (tenant, permissions, dates) from the verified user and the clock, put them in the store’s query on every path, never in your code after the fetch, and let a model suggest only soft ones.

Identity sets the hard filter; the model can only suggest soft ones

Wider than your screen? Scroll sideways.

Signed-in user token: tenant A, groups server clock: now HARD filter: never relaxed tenant_id = A acl, valid_from, valid_to Model reads the question, proposes a few fields SOFT filter: may be relaxed doc_type = policy product = enterprise Store search the store applies the filter 40,000 → up to 50 nearest that pass Prompt chunk text + source, page model: never

Related

More in RAG & MCP

Get full access to all 149 sections with code examples, diagrams, and interactive animations.

Unlock Premium