Metadata filtering
Definition
Narrowing a vector or keyword search with structured fields, such as date, language or access rights, before or during the search.
In more detail
Embeddings capture meaning but not hard constraints. If a user asks about the 2026 policy, similarity search may happily return the 2023 version. Storing fields such as document type, date, tenant and permission group with each chunk lets you filter to the right subset first.
Filtering by access rights is also a security control: retrieve only what the asking user may see, rather than trusting the model not to repeat restricted text. Most vector databases support filters, but heavy filtering can slow approximate search, so check the database's guidance.
Related terms
Chunking
Splitting documents into pieces sized for embedding and retrieval, ideally along natural boundaries such as sections or paragraphs.
Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.
Retrieval-augmented generation (RAG)
Retrieving relevant documents and adding them to the prompt before the model generates an answer from them.
Vector database
A database designed to store embeddings and quickly find the nearest neighbours to a query vector, often with metadata filtering.
Read more about Metadata filtering
- Embeddings and vector search, hands on
Embed documents, store them in Postgres with pgvector, index them and run similarity and hybrid search.
- Qdrant
Open-source vector database in Rust with payload filtering and hybrid search.
- Embeddings and vector search
Turning text into vectors to find similar items, alone or with keywords.