Metadata Filtering
Narrowing vector search by document fields: date, type, source, category.
Why Filters Are Needed
Vector search looks for meaning, but in real systems, this is not enough. Among the found items may be:
- old versions of instructions;
- documents for another product;
- drafts;
- documents in another language.
Metadata filters remove clutter before or during the search.
What Are Metadata
Metadata are fields attached to each chunk:
| Field | Example |
|---|---|
source |
manual_motor_x.pdf |
category |
guarantee |
product |
motor X |
date |
2025-11-20 |
lang |
ru |
How Filters Work
The query is turned into two conditions:
- Meaning: find chunks similar to the question.
- Metadata: only
product = "motor X"anddate >= "2025-01-01".
The vector database returns only those that pass both conditions.
Strategies
| Strategy | How It Works |
|---|---|
| Pre-filtering | Filter first, then search |
| Post-filtering | Search first, then filter |
| Filtered search | Filter is built into search |
The best is when the database supports filtered search out of the box — for example, Qdrant.