AskDocs v5: a VectorStore with filters
Handbook documents D1-old (2023) and D1 to D12 passages used here; D1-old is new in this phase. The embedder is a toy with four word groups.
AskDocs version 5 puts a VectorStore interface between the product and its vectors: upsert, delete and search with a filter. An in-memory version runs here, and a second version shows the pgvector SQL the same calls map to.
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.
Add count() to the in-memory store and delete_where(where) that removes every point whose payload matches the filter. Print the count before and after delete_where({"version": "2023"}) on a store with three points.
Write get(point_id) that returns (vector, payload) or None, and print None for a missing id. Why does a real adapter need this method for re-ingestion (Topic 4.7)?
Explain it without notes
What does the VectorStore interface contain, and what does each method return?
How does the version filter change the refund answer, and why not simply delete the old document?
How does the SQL version map search(vector, 3, {version: '2025'})?
Why are values passed as parameters but column names built into the text?
Expected output
Q: Can I get my money back if I cancel? [no filter]
sources: D1-old (0.98), D1 (0.98), D8 (0.83)
answer: A ride cancelled at least 6 hours before its start time is refunded in full. [D1-old]
Q: Can I get my money back if I cancel? [filter: version=2025]
sources: D1 (0.98), D8 (0.83), D2 (0.71)
answer: A ride cancelled at least 2 hours before its start time is refunded in full. [D1]
Q: I forgot my login, how do I get back in? [filter: version=2025]
sources: D3 (0.98)
answer: To reset your password, open the app, tap Forgot password and follow the link we email you. [D3]
Q: What does the monthly pass cost? [filter: version=2025]
sources: D8 (0.98), D1 (0.55)
answer: The monthly pass costs 25 dollars and includes unlimited rides of up to 45 minutes. [D8]
Q: Do you rent scooters? [filter: version=2025]
sources: none
answer: I can't find that in the handbook.
after deleting D1-old: 7 points