Skip to course content
Free RAG fundamentals course

Introduction to RAG and Knowledge Assistants

Unit 04.02: Rewriting for filters rather than for wording

Some parts of a question are not semantic at all. "Since 2025" is a date bound, and no amount of embedding will make similarity respect it.

Pulling exact constraints out of the text

A question usually mixes two kinds of content: a topic, which belongs in the vector search, and constraints, which belong in filters. Dates, sections, document types and permissions are exact. Similarity is not.

The example below parses two questions, separating the semantic remainder from the filters it can extract.

QUESTION                      SEMANTIC PART        EXACT CONSTRAINTS
"refund policy since 2025"    "refund policy"      updated after 2025-01-01
                                                   section = refunds
"what changed in billing"     "what changed"       section = billing

"Since 2025" is not a topic. A search for meaning has no way to represent a
date boundary, and a vector for 2025 sits close to one for 2024 -- which for
a date bound is worse than useless.

Dates, sections and permissions are exact. They belong in filters.

"refund policy since 2025" becomes a semantic query about refund policy plus updated_after: 2025-01-01. The date leaves the embedded text entirely, because a vector for "2025" is close to a vector for "2024" and that closeness is worse than useless for a date bound.

The same argument applies to section. "What changed in billing" carries a hard constraint - billing, not shipping - that the filter enforces exactly and similarity only approximates.

The mistake this prevents

The mistake is embedding the whole question and hoping similarity respects the constraint. It is the most common retrieval error in production systems: a user asks for recent policy, gets a confidently cited answer from 2021, and nothing in the pipeline recorded that the date was ignored.

Takeaway

Parse exact constraints into filters and embed only what remains. Dates, sections and permissions are boolean conditions; putting them in a vector search converts a hard guarantee into a soft preference.