Skip to Content
suntzu rcdocs
Bits

search.query — A visitor searches the whole site

  • Trigger: the search box (header button, ⌘K, Ctrl+K or / on any page; the "Search" item in the mobile menu), or the results page /search?q=… (Enter in the box, a shared link, the form on the page). Both call GET /search?q=… (optional type, one or more; miles 25/50/100; limit up to 30).
  • Who: anyone.
  • Path: box: apps/app/src/components/search/site-search.tsx → browserApi (apps/app/src/lib/search.ts, from the browser, no cookies). Page: apps/app/src/app/(site)/search/page.tsx → getPublicApi() (cached 5 minutes). Then SearchController → SearchService → runSearch (apps/api/src/search/search.ts): parseQuery (query.ts) reads the words, Spanish words, a kind of result, a town or ZIP code and pinned answers → each word corrected against search_words → full-text and trigram match on search_documents → closest places when a town or ZIP was named → the next edition of past events.
  • Data: reads search_documents (events, places and clubs written by the triggers in migration 0008; guides, rules and services written by the API when it starts), search_words, zip_codes, the towns of places and airports, and events (next editions). Writes nothing. The box keeps the last 5 searches in the browser's localStorage (servo.recent-searches), never sent anywhere.
  • Rules: only public things: events published and not rejected (the same rule as events.list), places, clubs and the site's content. Upcoming events rank above past ones; past ones are marked and point to their next edition. A town counts when it's the whole search or follows "near", "in" or "cerca de"; a ZIP code counts anywhere; then only what is within the radius shows, closest first (guides and rules stay; events, places and clubs without a place on the map don't). partial says no result has every word. Results are grouped (Events, Places, Clubs, Guides and rules), the group with the best result first. The results page is noindex. Cached 5 minutes; the words searched aren't logged. Closing the search box returns the focus to what opened it (the Search link, the phone menu's button), not to the top of the page (spec 0010).
  • Errors: an empty or longer than 100 characters search answers 400. Nothing found answers an empty list: the page and the box offer This weekend, Near me, Can I fly here? and Send us your event. If the API doesn't answer, the page says search is taking a break and the box offers the results page. Typo correction knows the words of the last refresh of search_words (at most every 5 minutes); a word that a document already holds stays as typed, so a new event's name is found at once (fixed 2026-11-18: "Palmxyzq" was "corrected" to "palm" for up to 5 minutes).
  • Test: e2e/search.query.e2e.ts (a new event found by name on the results page, upcoming before past, "Past" and its next edition, the tabs; the box with "/" and Ctrl+K, arrows and Enter, focus back to the Search link; nothing found → shortcuts in both; places and clubs; empty and too long → 400; a new name that looks like a word the site knows, found at once); what a search means in apps/api/src/search/query.test.ts (CI) and the 36 golden searches in apps/api/src/search/golden.test.ts (local database)
  • Observe: API log lines with bit: "search.query" and their time in ms.
  • Status: verified — 2026-11-18 (end-to-end test)