A metadata filter should narrow the search to one tenant, one document type or one date range before similarity is ranked. When the filter is misconfigured, the search can return chunks from the wrong tenant or the wrong year, and the answer will quote them as if they were correct. The check is to run the same question with and without the filter and compare what comes back.
Before you start
A vector collection with metadata fields on every chunk, such as tenant, document type and date, and a query interface that accepts filters.
Write filter test questions
Write five questions whose answers live in exactly one tenant or one document type. For each one, note the filter that should apply and the chunk that holds the answer.
Include one question where the same words appear in two tenants with different answers: that is the case a broken filter gets wrong.
Run with and without the filter
Run each question twice: once with the filter and once without. Record the top 5 chunks for each run and mark any chunk that comes from outside the filter.
If a chunk from outside the filter appears in the filtered run, the filter is not being applied. Stop and fix the index or the query before you test anything else.
Compare the result sets
Check that the filtered run returns the answer chunk and that every chunk in it passes the filter. Then check that the unfiltered run is different: if both runs return the same chunks, the filter may be doing nothing.
Record the pass rate per filter type so a regression in one filter does not hide behind the others.
Practice check: fictional Maple Corner index, tenants North and South
The table below is fictional practice material, worked out by hand from the stated runs. It is the expected result for the practice questions, not a run of any database.
| Question | Filtered top 5 | Outside-filter chunks | Verdict |
|---|---|---|---|
| North refund window | 5 North chunks | 0 | Pass |
| South warranty length | 5 South chunks | 0 | Pass |
| Return label, both tenants | 5 North chunks | 0 | Pass |
| South support hours | 4 South, 1 North | 1 | Fail – filter leaking |
Three of the four filtered runs are clean, but the South support-hours run leaks one North chunk. The filter works for most fields and fails on one, so the fix is in that field’s indexing, not in the query code.
Expected result. UNTESTED: the result sets in the practice table are worked out by hand, not measured by running a vector database. Run your own five filter questions with and without the filter and count the chunks that come from outside it.
Limits
- A filter that works on one metadata field can fail on another if the field was indexed with a different type or name.
- Filters narrow the search space; they do not improve the embedding quality of the chunks that remain.
