๐๐๐ถ๐น๐ฑ๐ถ๐ป๐ด ๐ฆ๐ฒ๐บ๐ฎ๐ป๐๐ถ๐ฐ ๐ฆ๐ฒ๐ฎ๐ฟ๐ฐ๐ต ๐๐ถ๐๐ต ๐ฝ๐ด๐๐ฒ๐ฐ๐๐ผ๐ฟ ๐ฎ๐ป๐ฑ ๐ข๐ฝ๐ฒ๐ป๐๐
Keyword search fails users. A user searches for a funny cat. Your system finds nothing. The video title uses slang. This happened to 31% of our users.
We fixed this with semantic search. This finds meaning instead of words. We used pgvector and OpenAI embeddings.
Our setup:
- Main site runs on SQLite.
- Search runs on Postgres 16 with pgvector.
- This split protects user data. Only video metadata goes to the US API.
How we saved money:
- Embeddings cost money.
- We use a content hash.
- We skip the API call if text stays the same.
- This cuts costs by 94%.
How we improved accuracy:
- Do not embed only the title.
- Combine title, channel, tags, and description.
- Add a small lexical increase for exact matches.
- This gives you better results.
How we improved speed:
- Use Cloudflare Workers.
- Cache popular searches at the edge.
- 70% of searches now cost zero API calls.
The results:
- Zero result rate dropped from 31% to 4%.
- Latency is under 10ms for cached terms.
Three lessons for you:
- Embed a structured document.
- Hash content to stop wasting money.
- Pair semantic search with lexical signals.