Skip to content

Get startedExercises

Exercise 01: trace a search

2 min readUpdated

Page actions

ChatGPT and Claude are third-party services. The link gives them this page's public address and a short instruction. This site records nothing.

Run three real queries through the search waterfall — one the exact tier answers, one the lexicon answers, one that falls to the fold — and read the reported mode against the code.

Goal. Predict which tier answers a query, run it, and confirm from the mode the API reports. Needs. A local server (python3 webapp/serve.py) or the production API through the wiki’s simulator. 30 minutes.

1. Predict

Read modes and tiers. For each query below, write down the tier you expect and the mode string it would report:

QueryYour prediction
sat nam
waheguru
zzqxv plok

2. Run

Terminal window
curl -s 'http://127.0.0.1:7777/api/search?q=sat%20nam&limit=3' | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["mode"], len(d["results"]))'
curl -s 'http://127.0.0.1:7777/api/search?q=waheguru&limit=3' | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["mode"], len(d["results"]))'
curl -s 'http://127.0.0.1:7777/api/search?q=zzqxv%20plok&limit=3' | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["mode"], len(d["results"]))'

Expected output (the second line’s term in brackets may differ by dataset):

variant-match 3
seeker-lexicon (vaahiguroo) 3
roman-spelling-tolerant 0

3. Read the code

Open webapp/sggs/search.py and find do_search. For each query, find the line that set the mode you saw. Then answer:

  • Why did sat nam skip the transliteration tier? (Hint: what does the translit column hold for the line whose transliteration is sat naam?)
  • Why is the last query’s mode a fold tier with zero results, rather than NOT_FOUND?

Self-check