Semantic Search for $0: How Cloudflare Put a Real Search Engine on My Blog

I embedded 210 posts locally, processed each query at the edge, and blended semantic and keyword search without adding a monthly bill.Generated by OpenAIThere is a particular flavour of frustration that only hits people who write things down.You know you wrote about it. You can picture the…

I embedded 210 posts locally, processed each query at the edge, and blended semantic and keyword search without adding a monthly bill.Generated by OpenAIThere is a particular flavour of frustration that only hits people who write things down.You know you wrote about it. You can picture the paragraph. You remember being pleased with a sentence in it. So you type what you remember into your own search box — how do I keep code from blocking — and your own blog, which contains eight posts on exactly that, looks you in the eye and says: no results.The posts were right there. Every one of them was about waiting, blocking, concurrency, event loops. Not one of them contained the phrase I typed. The search box wasn’t broken. It was doing precisely what it was built to do: match words. I just hadn’t given it the right ones, because I was describing an idea, and it only knew how to hunt for strings.That gap, between the words you remember and the words that were written, is where most search boxes on the internet quietly fail. And closing it used to be something you paid a company for, every month, forever.It isn’t anymore. That’s what this post is about.What “understanding” actually meansHere’s the idea that makes modern search feel like magic, minus the magic.Imagine a map. Not of places, of meanings. Every idea gets a position on it. “Dog” sits near “puppy” and a good distance from “tax return.” “Waiting for a slow database” lands in the same neighbourhood as “keeping your program responsive,” even though those two phrases share no words at all.Now imagine that map has a thousand dimensions instead of two, and that a machine has read enough text to place almost any sentence on it, in any language it knows.That’s an embedding. You hand a model a chunk of text; it hands back a long list of numbers, coordinates. Two texts about the same thing land close together. Two texts about different things land far apart. The words themselves stop mattering. Only the meaning does.Once every post on your blog has coordinates, search becomes something almost embarrassingly simple: put the visitor’s question on the same map, then look around it. Whatever’s nearby is the answer.That’s how “how do I keep code from blocking” now finds a post called Asyncio Best Practices and Common Pitfalls — a post which, I promise you, does not contain the word “blocking” anywhere a keyword search would find it. The engine scored its keyword match at zero and its meaning match at 0.98, and put it near the top. It found it by understanding it.The first time that worked, I sat back in my chair and grinned at a search box. Which I recognise is not normal behaviour.The part that used to cost moneySo why doesn’t every small site do this?Because for a long time, the map was the expensive bit. You needed a model big enough to be good, hardware to run it on, and somewhere specialised to keep all those coordinates. The industry’s answer was to rent it: Algolia, Elastic, Pinecone, and friends will all happily do this for you, and they will all happily send you a bill every month for as long as your site exists.For a business, fine. For a personal blog that makes exactly zero dollars, a recurring bill for a search box is an absurd thing to sign up for. So personal sites mostly settle for keyword matching, or for whatever their site generator ships, or for a Google search scoped to their domain.The unlock is a split that seems obvious once you see it, and didn’t occur to me for embarrassingly long:The expensive work only has to happen once. The cheap work is the only part that has to happen live.Reading 210 posts and working out what each one means is genuinely heavy lifting. But my posts don’t change while you’re reading them. That work can happen on my own desktop, at 2 am, on hardware I already bought for other reasons, and it produces a file.Understanding one visitor’s question, on the other hand, is tiny. One short sentence. One trip through the model. That’s the only part that has to happen at the moment someone types.So: do the heavy thing at home, once. Ship the result. Do the tiny thing live.What Cloudflare just…gives youHere’s where I got genuinely excited, and it’s the reason this post exists.Cloudflare has quietly assembled every piece this design needs, and put all of them on a free tier that a personal blog will never come close to exhausting:A place to run code, close to whoever’s visiting.A database that lives out there with it.AI models you can call, including good multilingual embedding models, the same class of model I run at home.That last one is the piece that changes the arithmetic. It means the model that reads my posts on my desktop and the model that reads a visitor’s question at the edge can be the same model. Same map. Same coordinate system. My posts and your question end up in the same space, so measuring the distance between them actually means something.The whole corpus — every post, both languages, as coordinates — comes out to 281 KB. That’s a third of a floppy disk, and it holds the meaning of everything I’ve ever published here. It sits in a small database at the edge. When you type a question, one model call turns your words into coordinates, and the code compares them against all 210 posts.No vector database. No monthly bill. No service to sign up for. The comparison is simple enough arithmetic that doing it 210 times is faster than asking a specialised service to do it once.I keep coming back to how available this is now. This isn’t a scrappy approximation of what the big sites have. It’s the same technique, using models of the same generation, running on the same kind of infrastructure. The gap between “personal blog” and “production search” has closed, and a lot of people haven’t noticed yet.Two engines, because both are liarsNow the part that took me the longest to accept: meaning-based search alone is not good enough.It has a specific and fatal charm, it always has an answer. Ask it anything and it will confidently return the closest thing on the map, because something is always closest. There’s no such thing as “no match.” There’s only “least far.”I asked my blog, in Chinese, how to stop my API from stalling. The second result was a post about buying a toaster.It’s not a bug. It’s a post about networking that happens to open in an appliance shop, and on the map of meanings it drifted close enough to a question about slow connections to land at number two. Meaning-search has no way to say “actually, none of these.” It just ranks and shrugs.Old-fashioned keyword search has exactly the opposite personality. Ask it for SQLAlchemy and it will find the four posts that literally say SQLAlchemy, hand them over, and stop. It is completely blind to anything phrased differently - but when it does find something, it's certain, and it knows when to shut up.One is imaginative and can’t tell when it’s wrong. The other is literal and can’t see past the exact words. So the blog runs both on every search and blends the two scores into a single list. Between them, they cover each other’s blind spots: meaning finds the post you couldn’t name, keywords keep the toaster in its place.Then I tried it in ChineseThe blog is bilingual, and this is where a comfortable assumption fell over.English is easy to chop into words, because English helpfully ships with spaces between them. Chinese doesn’t. A Chinese sentence is a continuous run of characters, and knowing where one word ends and the next begins is something you either learn or look up.The database underneath my keyword search doesn’t know either. Handed a Chinese sentence, it shrugged and treated the entire thing as one enormous word. Which means the only way to match it was to type that entire sentence, character for character, exactly. Ask a real question, and you’d get nothing.The fix is a nice piece of lateral thinking: if you can’t teach the database where Chinese words end, stop trying. Instead, chop every sentence into overlapping character pairs before storing it. Do the same to the question. Real Chinese words are mostly two characters long, so the pairs that matter line up on both sides, and the database gets to do ordinary keyword matching without knowing a single thing about Chinese.It’s a small trick, and it delights me. The meaning-based half needed no such help; incidentally, the model was trained on both languages, so Chinese questions and Chinese posts land on the same map as everything else — no cleverness required.What it feels like nowType into the box and results appear immediately, before any network request, because a small index of every post’s title rides along inside the page itself. Then, a beat later, the real answer arrives from the edge and quietly replaces it. Press Enter, and it goes away to think properly, blending meaning with keywords.The whole search experience adds about 14 KB to the page. The previous setup, a conventional index of the same 210 posts, with no understanding of meaning whatsoever, was 13 MB. Roughly a thousandth of the size, and it’s the one that knows what the posts are about.And the bill is zero. Not “cheap.” Not “a few dollars.” There is no bill.That’s the part I want to leave you with, and it’s bigger than my little search box. The tools that searched feel intelligent were, until very recently, things you rented from someone. Now the model is a free API call, and the storage is a free database, and the code runs free at the edge, and the only thing standing between a hobby project and a genuinely good search engine is an afternoon and the willingness to try.If you keep a blog, or a wiki, or a pile of notes you can never find anything in, go and look at what’s sitting on the free tier. I think you’ll be surprised what’s just there now, waiting for someone to pick it up.I searched my own blog for a half-remembered idea this morning, in the wrong words entirely, and it knew what I meant.Small thing. Still grinning about it.This story is published under the Generative AI publication. Connect with us on LinkedIn and follow Zeniteq to stay in the loop with the latest AI stories. Let’s shape the future of AI together!Semantic Search for $0: How Cloudflare Put a Real Search Engine on My Blog was originally published in Generative AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source: Generative AI Pub — Published — Category: Image AI

🔗 Read full article on Generative AI Pub →