Full archive search
Section titled “Full archive search”NutsNews full archive search is backed by PostgreSQL full-text search in Supabase.
Database pieces
Section titled “Database pieces”The migration adds:
articles.search_vector, a generatedtsvectorcolumnarticles_search_vector_idx, a GIN index for fast searcharticles_search_published_idx, an index for published story orderingpublic.search_articles(search_query, page_size, page_offset), an RPC function used by the web API
Search weights:
- Title: A
- AI summary: B
- Source: C
- Category: C
Web API
Section titled “Web API”The API route is:
GET /api/search?q=dogs&page=0&limit=20Response shape:
{ "articles": [], "nextPage": null, "query": "dogs", "page": 0, "pageSize": 20, "languageCode": "en"}Home page UX
Section titled “Home page UX”The search box is built into the existing home feed component:
web/app/components/ArticleFeed.tsxWhen a user searches, the home page switches from normal feed mode to archive search mode. The clear button returns to the normal feed and infinite scroll.
Local tests
Section titled “Local tests”cd /Users/ramideltoro/WebstormProjects/nutsnews3/webnpm run buildnpm run devThen:
curl -s "http://localhost:3000/api/search?q=dogs&limit=5" | python3 -m json.toolcurl -I "http://localhost:3000/api/search?q=dogs&limit=5"Open:
http://localhost:3000Search for dogs, community, science, and a nonsense query like zzzzzzzzzz.
