IplanRio2025–2026in production
Public service search and recommendations
Hybrid search that connects how residents phrase a need to the official names of city services, courses and jobs.

519
requests per second at the load test peak
- 0%
- errors across 238,000 requests
- 3
- retrieval strategies fused with RRF
The problem
Residents describe their needs in their own words, while the catalog uses each service's official name. Full-text search alone could not bridge that gap, and services, courses and jobs were spread across separate stores.
The solution
I built a discovery layer in Go on PostgreSQL with pgvector, pg_trgm and unaccent. Each query is expanded with synonyms and, in parallel, produces an embedding of the question and a hypothetical document (HyDE) generated by Gemini. Portuguese full-text search, the question vector and the HyDE vector are fused with Reciprocal Rank Fusion, and the top 20 results go through a cross-encoder reranker.
Technical notes
Staged degradation. If Vertex AI does not respond within 4 seconds, search falls back to two strategies and, if needed, to full-text only.
Profile-based recommendations across six dimensions, including education, income, location, accessibility and age group.
CPF numbers (Brazilian taxpayer IDs) are never stored in clear text, in the database or the cache, only as salted hashes.
On the previous Typesense version, I added automated page crawling and an LLM service for document ingestion.
Outcome
In a staging load test, the service handled 238,000 requests with a peak of 519 per second and no errors. The analysis also traced elevated latency on part of the queries to retries against a deprecated embedding endpoint.