Compaction trigger and the migration overlap check
Ready-to-copy recipes for any vector store: a schema and index template, a query template with parameters, the sizing function, a compaction trigger, a migration overlap check and a blue-green re-index.
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 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write overlap_at_k(old, new) and print it for ["D1", "D6", "D2"] against ["D1", "D2", "D9"] with 2 decimals.
Write switch_alias(aliases, name, new_collection, new_rate, old_rate) that points the alias to the new collection only if new_rate > old_rate and returns the collection now served. Print the result for rates 0.9 and 0.8, then for 0.7 and 0.8.
Explain it without notes
Give the steps of a blue-green re-index and what each protects against.
What does an overlap check tell you, and what does it not?
Why does the schema fix the vector length?
What should a vector-store canary set contain?
Expected output
live=90 dead=10 -> compact: no
live=75 dead=25 -> compact: yes
live=0 dead=0 -> compact: no
refund overlap 1.00 old=D1,D6,D2 new=D1,D6,D2
login overlap 0.67 old=D3,D5,D1 new=D3,D1,D10
pass overlap 0.67 old=D8,D6,D12 new=D8,D12,D4
mean overlap 0.78, flagged: login, pass