Retrieval
Recency in RAG retrieval: filter, boost or decay by date
Choose between a hard date filter, a capped decay boost and a half-life recency prior for time-aware RAG retrieval, and store dates that can carry the choice.
By Rose Donaldson, Context Retrieval team · Published
This article was drafted with AI assistance from the sources listed below and edited and published by the Context Retrieval team.
- 1Store the published dateTake it from the page; leave it empty when the page states none, never the fetch time.
- 2Filter dated questionsUse a hard date filter only when the question or product context names a period.
- 3Boost, cappedAdd a small decay term, such as 0.1 times exp_decay, so newer chunks win only close races.
- 4Tune a priorIf you mix similarity and 0.5^(age/h), tune alpha and h on your own dated questions.
Some questions have a date hidden in them. "What is the current rate limit?" wants the newest page that states one. "What did the advisory say in March?" wants a page from March and nothing later. A plain vector search answers neither well, because cosine similarity has no idea when a passage was written. Two copies of a pricing page, a year apart, can sit almost on top of each other in embedding space, and the retriever will return whichever scores a hair higher.
There are three common ways to give the retriever a sense of time: a hard date filter, a capped boost added to the score, and a recency prior mixed into the score. They answer different questions, and all three depend on a date field you can trust. This post covers that field first, then each method, then how to test the choice on your own golden question set.
The date field comes first
Every method below reads a published date from chunk metadata. For web pages, store the date the page itself states, for example in its byline or its structured data, and copy it to every chunk of that page. Many pages state no date at all. For those, leave the field empty.
Do not fill an empty published date with the fetch time. The fetch time is when your pipeline read the page; a reference page last edited three years ago and fetched this morning would then look brand new, and every recency method would promote it. Keep the two as separate fields: the fetch time tells you when to re-fetch, the published date feeds ranking. Decide up front how ranking treats a chunk with no date. The safe default is neutral: no match for a date range, and no recency credit.
Method 1: a hard date filter
A date filter drops every chunk outside a range before or during the search. It is the right tool when the question names a period or an as-of date. Grofsky's temporal RAG paper treats as-of queries this way: the system restricts its knowledge base to documents up to the requested date.1 The same paper is candid about what that test shows. Its as-of score of 1.00 is a pass/fail result over 3 queries, which the author describes as a check that the filter is correct rather than a measure of accuracy.1 A filter does not rank anything; it only narrows the pool.
The cost of a filter is what it hides. A question with no stated period, filtered to the last 90 days, loses every older page, including the one stable reference page that still answers it. Use a filter only when the date comes from the question or from the product context, the same rule as for a version filter in versioned documentation.
Method 2: a capped decay boost
A decay boost keeps the relevance score and adds a small date-based term to it. Qdrant has supported this since v1.14.0 through formula queries.2 Its decay functions (lin_decay, exp_decay and gauss_decay) take a value x, a target, a scale and a midpoint. The output peaks at the target and equals the midpoint at a distance of one scale from it; the defaults are a target of 0.0, a scale of 1.0 and a midpoint of 0.5.2 A payload key can be read as a datetime, which is parsed to a POSIX timestamp in seconds, so the scale for dates is also in seconds.2
An example in Qdrant's hybrid-query docs adds 0.1 × exp_decay on a published_at field, with a scale of 180 days written as 86400 * 180 and a midpoint of 0.5, to the score from a fused prefetch.3 The comment in that example explains the 0.1: it caps how much the decay can contribute, so it does not crowd out small fusion scores.3 That is the point of this method. A newer chunk wins a close race, but a clearly more relevant older chunk still wins.
Check how your store handles a chunk with no date. Qdrant lets you set a fallback value for a missing variable through a defaults mapping next to the formula.2 Set it on purpose so that undated chunks get the neutral treatment you chose, rather than whatever the engine does without one.
Method 3: a half-life recency prior
A recency prior goes further and mixes similarity and age with a weight. The temporal RAG paper scores each document as α·cos(q, d) + (1 − α)·0.5^(age_days / h), where h is the half-life in days.1 Its defaults are α = 0.7 and h = 14, and it measures age from the newest timestamp in the corpus rather than from the clock, which keeps re-runs deterministic.1
A worked example with those defaults. Chunk A has a similarity of 0.82 and is 60 days old; chunk B has 0.78 and is 3 days old.
def recency_score(cos_sim: float, age_days: float, alpha: float = 0.7, half_life: float = 14) -> float:
return alpha * cos_sim + (1 - alpha) * 0.5 ** (age_days / half_life)
print(round(recency_score(0.82, 60), 3)) # chunk A: 0.589
print(round(recency_score(0.78, 3), 3)) # chunk B: 0.805
B now ranks first by a wide margin, even though A was the closer match. With α = 0.7, the recency term can move a score by up to 0.3, three times the 0.1 cap in the boost above. That is why the weight matters so much.
The paper's results show both that the method helps and where it stops. On a test with 4,500 NVD CVE records, where the newest relevant item is not the most similar, cosine-only retrieval scored 0.00 on Latest@10, a semantic-then-newest baseline 0.20, the prior at α = 0.7 scored 0.40, and at α = 0.3 with h = 14 it scored 0.60, over 5 queries.1 On CERT logon data, the default setting scored 0.00 and a tuned setting (α = 0.3, h = 3) scored 1.00, over 2 queries.1 The author's conclusion is that freshness through a recency prior is "real but partial and parameter-sensitive, not solved", and that the recency weight has to scale with the density and timespan of the corpus.1 These are small query counts on security data, not web pages. Treat α and h as settings to tune, not constants to copy.
A recency method that is not about dates
LangChain's time-weighted retriever looks similar and measures something else. Its score is (1.0 - decayRate) ** hoursPassed + vectorRelevance, where the hours count from the last time the retriever accessed the object, not from when it was created.4 A decay rate of exactly 0 or 1 turns it back into a plain vector lookup.4 It rewards documents that are used often, which suits an agent's memory. It does not prefer new pages over old ones, so it is the wrong tool for a question about the current rate limit.
Choose on your own questions
Add a handful of dated questions to your golden set: some that name a period, some where the newest page is the right answer, and some where an old reference page is. Run them with no recency method, with a filter for the period questions only, with a capped boost, and with a prior at two or three values of α. Read the misses. If the prior pushes stable reference pages out of the top-k, lower its weight or fall back to the capped boost. The comparison on your own pages is the one that counts.
Footnotes
-
Grofsky, "Freshness and the Limits of Heuristic Trend Detection in Temporal RAG", arXiv 2509.19376 (v2, June 2026). Figures on the author's own test sets. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7
-
Qdrant documentation, "Search relevance" (score boosting and decay functions). ↩ ↩2 ↩3 ↩4
-
Qdrant documentation, "Hybrid and multi-stage queries" (formula query example). ↩ ↩2
Frequently asked questions
How do I make a RAG system prefer newer documents?
Store a published date on every chunk where the page states one, then either filter on a date range or add a recency term to the relevance score. A filter suits questions about a fixed period; a recency term suits questions where newer is usually better but not always.
What is a half-life recency prior in RAG?
A score that mixes semantic similarity with a decay term, 0.5 raised to the document's age divided by a half-life h. A document one half-life old gets half the recency credit of a brand-new one. The weight between similarity and recency has to be tuned to your corpus.
Should I use the fetch time as the date of a page with no published date?
No. The fetch time says when you read the page, not when it was written, so an old page fetched today would look new. Leave the published date empty and give such chunks no recency boost.
Does LangChain's time-weighted retriever rank by publication date?
No. Its decay counts the hours since a document was last accessed in the retriever, so it rewards documents that are used often, not documents that are new.