๐ฆ๐ฒ๐บ๐ฎ๐ป๐๐ถ๐ฐ ๐ฆ๐ฒ๐ฎ๐ฟ๐ฐ๐ต ๐๐ถ๐๐ต ๐ฝ๐ด๐๐ฒ๐ฐ๐๐ผ๐ฟ ๐ฎ๐ป๐ฑ ๐ข๐ฝ๐ฒ๐ป๐๐
Keyword search failed 31% of your users.
A user types "funny cat." The video title says "Maine Coon jumps." Keyword search finds nothing. Slang and emojis break these searches.
The fix is semantic search. Turn text into vectors. Compare vectors to find a match.
The technical stack:
- SQLite for the main site.
- Postgres 16 with pgvector for search.
- OpenAI for embeddings.
- Cloudflare Workers for caching.
Save money with hashes. Check if text changed before calling the API. This cut costs by 94%.
Improve accuracy with a hybrid approach. Semantic search finds the meaning. A simple text match finds exact words. Combine both for better results.
GDPR safety: Send only video metadata to the API. Keep user data in the EU.
The results:
- Zero-result rate fell from 31% to 4%.
- p50 latency under 10ms with caching.
- Initial cost was 42 dollars.