Library// definition

Metadata filters, and the difference between filtering and ranking

In short

A metadata filter is a binary admissibility rule: a passage either satisfies it and may compete for a place in the results, or it does not and cannot be returned at all. A boost is continuous, moving a passage up or down a list it is already in. Filters produce empty result sets; boosts produce buried ones. Anything driven by entitlement has to be a filter.

Key takeaways

  • A filter changes who is allowed to compete. A boost changes who wins. They fail in opposite directions.
  • Entitlement, tenancy and legal scope are filters. Recency and source preference are boosts.
  • Every filter you might want has to exist as a field at index time. Retrofitting one means a reindex.
  • A filter matching a tiny slice of the corpus is not a filter, it is a different query.

A metadata filter is a rule over the structured fields stored with each chunk — source, date, department, document type, tenant, permission key — deciding which passages may be returned at all. It is binary: a passage that fails it is not ranked low, it is not in the running.

That is the whole distinction from a boost, and worth being pedantic about: the 2 are described with the same words in most documentation and fail in opposite directions. A filter set too tight returns nothing. A boost set too weak returns everything, in a slightly better order.

Admissibility is binary, preference is continuous

PropertyHard filterScore boost
What it acts onMembership of the candidate setPosition within a set already chosen
Effect of getting it wrongNothing comes back, or something that should not haveThe right passage comes back in the wrong place
Right forEntitlement, tenancy, jurisdiction, effective datesRecency, source authority, format preference
AuditabilityA predicate you can state, test and show a reviewerA weight whose effect depends on every other score in the list
The 2 mechanisms, compared on the properties that decide which a requirement needs

The last row settles most arguments. A filter is a statement someone can read: this query considered only documents this user may open. A boost is a number whose behaviour shifts with every list, so it underwrites nothing.

The fields worth carrying on every chunk

Filters can only use fields that exist at query time, so what to store is decided at ingest, long before anyone knows which filter they need. Retrofitting one means a reindex.

  • Tenant and permission key. The 2 fields that must never be a boost, and worth testing on every release.
  • Source system and native record id. Lets you exclude a whole connector after a bad import, and a citation resolve to something a person can open.
  • Document type and status. Draft, superseded, approved, template — the most useful filter in most corpora, and usually the last one added.
  • Effective and expiry dates, distinct from the ingest date. A policy live from April and replaced in September needs both, and neither is the day it was indexed.
  • Content hash and pipeline run id. Operational rather than user-facing, and the difference between isolating a bad batch and rebuilding all of it.

Filtering before the search and after it are different algorithms

Post-filtering runs the search first and discards candidates that fail the rule. It is trivial on any store, and it silently shrinks the result set: the search had no idea the filter existed when it chose those candidates.

Pre-filtering restricts the space before or during the search, so every candidate is admissible. It needs index support, and the cost lands on the engine: against a very selective condition an approximate index may widen its search or fall back to scanning, so latency becomes a function of how much of the corpus the filter admits. That data-dependent tail is what an objective must be written against, not an average — the distinction in SLA versus SLO for an AI feature.

Between them sits over-fetching: ask for more candidates than you need, then post-filter, accepting that the multiplier is a guess. It holds while filters are loose and breaks when someone adds a narrow one — recall collapsing the day permission filtering was turned on.

A boost demotes a passage the user may not see. A filter means it was never a candidate. Only one is a permission model.

Why a filter mistake is quieter than a ranking one

A bad ranking is visible: the answer is weaker, someone complains, you look at the order. A bad filter destroys the evidence of its own mistake. The passage that would have answered is absent rather than low, and the model composes something confident from what survived.

  • An overly tight condition returns 2 passages instead of 10, so the answer reads thin rather than wrong.
  • A filter value derived from the question can be extracted wrongly — last year becoming the wrong date range — a failure of query rewriting before retrieval, not of the filter.
  • An exact-match predicate over free text is brittle in the way lexical and semantic retrieval fail differently describes: Legal and legal-department differ.
  • A filter applied to only one arm of a hybrid search leaks through the other, which is how permission bugs survive code review.

Because filters decide which evidence is admissible, they decide what an answer can be supported by. An assistant that filtered out the governing document and answered anyway produced something confident and unsupported — groundedness as a property of an answer. Log the filter set beside the query, as part of that answer's provenance.

Choosing which metadata to capture is a schema decision taken in the first version, when it is cheap, rather than after the first reindex, when it is not — which is why we treat retrieval metadata as product design in MVP and product builds. Where the permission check sits is adding permission filters to retrieval. Neighbouring terms are in retrieval and grounding, part of the engineering library.

Frequently asked questions

Short answers to the follow-ups this page tends to raise.

What is metadata filtering in vector search?

It is a rule over the structured fields stored with each chunk, deciding which passages may be returned at all. Unlike a similarity score it is binary: a chunk failing the rule is excluded from the candidate set rather than ranked lower. Typical fields are tenant, permission key, document type and effective date.

What is the difference between pre-filtering and post-filtering?

Pre-filtering restricts the searchable space before or during the search, so every candidate is admissible. Post-filtering searches first and discards afterwards, so a selective filter can leave a handful of results or none. It is easier to build and quietly reduces recall.

Should permissions be a filter or a ranking signal?

Always a filter, applied inside the search rather than after it. A ranking signal only demotes a passage, leaving it in the candidate set where a weight change or a debug flag can promote it back. Entitlement is a question about admissibility, so it belongs where admissibility is decided.

Why does adding a filter sometimes return no results at all?

Because it is applied after the candidates were chosen and admits too small a share of them. If a condition matches 1 chunk in 1,000 and you retrieve 100 candidates first, most queries return nothing. Push selective conditions into the search.

  • metadata
  • filtering
  • vector search
  • definitions
// shipped work

The work behind this page

Builds from our portfolio that this page draws on.

Working on something in this space?

Tell us where you are in a sentence or two. We'll tell you honestly whether we're the right team, and what a sensible first slice of the work looks like.

Start the conversation