Skip to content

Metadata and Filters in RAG

Summary

Metadata are document characteristics: date, type, source, category. Metadata filters help search not just by meaning, but by the intended meaning in a specific subset of documents.

Why Use Filters

Regular vector search looks for meaning. But in real systems, this is not enough.

Imagine: you have a database of 100,000 documents—manuals, contracts, letters, articles. The user asks:

"What is the warranty on motor X?"

Vector search will find similar meaning fragments, but among them may be:

  • old versions of the manual;
  • documents for another product;
  • drafts;
  • documents in another language.

Metadata filters remove clutter before or during the search.

What Are Metadata

Metadata are fields that you attach to each chunk:

Field Example
source manual_motor_x.pdf
category warranty
product motor X
date 2025-11-20
lang ru
version 3.2

How Filters Work

The query is turned into two conditions:

  1. Meaning: find chunks similar to the question.
  2. Metadata: but only `product =