Listen: How we built Search for Agents on dejan.ai without Cloudflare

How dejan.ai built a self-hosted /.well-known/search API without Cloudflare: gemini-decision-1 boundary classification, gemini-embedding-2 contextual vectors, and PostgreSQL pgvector hybrid search across 5,718 chunks.

Listen

Transcript

We built a self-hosted search endpoint on our website, upgrading our search for both humans and AI agents.

Traditional search often chops up articles at random, breaking up important context. On the other hand, asking a generative artificial intelligence model to rewrite and chunk text is slow and risks losing information.

We solved this by framing semantic chunking as a simple series of yes-or-no decisions. Using a decision model, we analyze the transition between adjacent blocks of text, asking if one block ends a complete idea before the next begins. Because the model only makes decisions and never rewrites the text, our content remains perfectly verbatim. This approach runs incredibly fast and completely eliminates orphan headings.

To keep search highly accurate, we prepend the title and section context to each chunk before embedding. Everything is stored in a single PostgreSQL database. We use a hybrid approach that combines traditional keyword matches with modern vector search to pull the most relevant results.

Now, a single database table serves both of our search interfaces. Human visitors get rendered HTML with highlighted query terms, while AI agents hitting our search endpoint receive clean Markdown passages. We backfilled our entire database of over two thousand items in just over three minutes, giving us a fast, reliable, and entirely self-hosted search pipeline.