Blog

Semantic Search for WordPress with Qdrant and Ollama

A practical guide. No hype, no subscriptions, no third-party data.

More than 40% of the web runs on WordPress, according to W3Techs statistics, but the built-in search doesn’t understand what it reads: it only finds literal words. Search for "electric car" and the article about "electric mobility" won’t show up, even though it covers exactly that. There is a solution, and it runs on your own server: semantic search built on Qdrant and Ollama, without your content ever leaving home.

The Built-In Search Matches Letters, Not Ideas

WordPress stores every post in MySQL, and when someone uses the search box, it fires off a LIKE query that requires the words to appear exactly as typed in the title or the content. It’s a string-matching search. The engine doesn’t know that "car" and "vehicle" refer to the same thing, or that "rate" and "price" are about the same subject. On a small blog you barely notice; as the archive grows, readers leave without finding what they came for.

The alternative isn’t a faster search engine — it’s one that works with meaning.

Search by Meaning, Not by Literal Match

Semantic search changes the unit of measurement. An embedding model converts each piece of text into a list of numbers — a vector that represents its meaning — and two texts that cover the same topic end up with vectors that sit close together even if they don’t share a single word. Comparing a query against your entire archive then comes down to measuring distances.

Qdrant was built for exactly that: it’s an open source vector database, written in Rust, that stores vectors and returns the closest matches using cosine similarity. The vectors themselves are generated by Ollama, on your own machine. Lightweight models like nomic-embed-text, with 768 dimensions, are a good starting point, though if your content is in Spanish, a multilingual model like bge-m3 makes more sense, because embeddings centered on English do a worse job of capturing meaning in other languages.

How the Three Pieces Talk to Each Other

The flow involves three actors. A small script queries the WordPress REST API, available at /wp-json/wp/v2, and downloads your posts, which are split into chunks of a reasonable size, because the vector of a very long text dilutes its meaning. Ollama then turns each chunk into a vector, and the script stores it in Qdrant along with a link to the original post. When a visitor types a query, it is also converted into a vector, and Qdrant returns the closest chunks, with their links.

The result is no longer a list of posts containing your literal words: it’s the passages that deal with the topic, even if they use different vocabulary. That’s where RAG — retrieval-augmented generation — comes in: the retrieved chunks are handed as context to a local model, for example Llama 3 or Mistral served through Ollama, and the model writes a response grounded in your own archive, with links to each post.

One obligation remains that you can’t dodge: when you edit a post, its vector becomes stale. The fix is to reindex that post, either with a webhook that notifies the script or with a scheduled reindexing.

What Hardware You Need and What It Costs

The whole setup is free and open source: Ollama is distributed under the MIT license, Qdrant under Apache 2.0, and the Qdrant container starts with Docker and exposes port 6333. The real requirement is memory: a small embedding model fits on modest machines, but if you want a local LLM writing responses, the server needs resources to match the model you choose. The economic advantage is that there’s no per-token bill, because paid APIs charge for every piece of text processed, and that cost disappears when the model lives on your machine.

If you’re wondering what local AI really costs compared to a subscription, we break it down with numbers in What Does Your AI Really Cost?. And if you haven’t taken the first step yet, this guide to connecting Ollama with WordPress gets your server ready before you touch Qdrant.

Start with Ten Posts

That number from the opening still stands: more than 40% of the web runs on WordPress, and nearly all of that volume is searched by letters. The experiment fits into an afternoon: spin up the Qdrant container, index ten posts with Ollama, and run a query with synonyms your current search would never find. If the results convince you, the same script can work through your entire archive without changing a single piece of the machinery — and without asking any cloud for permission.

Try it in 3 minutes

Install Ollama + Open WebUI on your computer, free and private.