Filters, freshness, citations and deletion
Dates are ISO strings so they compare correctly as text. c4 is French and c2 is staff-only; c1old is an outdated version of c1.
Metadata is the labelled information stored next to every chunk: source, section, date, version, language and who may read it. Each field exists because a later step needs it, and a schema that is checked at ingestion keeps bad records out.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write newest(chunks) for a list of (source, version) pairs that keeps only the pair with the highest version for each source, preserving order. Print the result for [("a", 1), ("b", 1), ("a", 2)].
Write is_iso_date(text) that returns True when the text looks like YYYY-MM-DD (digits only, with dashes in the right places). Print it for "2026-03-01" and "1 March 2026".
Explain it without notes
Name four metadata fields and what each is used for later.
Why validate metadata when chunks are created and not when they are searched?
Why filter by access before ranking rather than after?
Why is metadata usually not part of the embedded text, and when is an exception sensible?
Expected output
all: c1 c1old c2 c3 c4
public reader, English: c1 c1old c3
newest version only: c1 c3
staff reader, English: c1 c2 c3
citation: refunds.md > Booking (updated 2026-03-01, version 2)
after deleting refunds.md: c2 c3 c4