You will understand what vector similarity is, why it measures meaning instead of words, and how EngineerPrep uses it to power semantic question search with pgvector and Spring AI.
A learner opens EngineerPrep and types: "how do trees work in interviews." Your question bank has a great match: "Explain binary search tree traversal." But your search returns nothing useful. You check the database. The question is right there. The problem is your search only looks for exact words — and the query's phrasing shares no tokens with the question title. The meaning matches perfectly. The words do not. Your first instinct is to add synonyms, or fuzzy matching, or maybe a big list of related terms. But that road never ends. There are always more synonyms, more phrasings, more ways to say the same thing. There has to be a better way to compare meaning directly. That better way is vector similarity — and by the end of this lesson, you will know exactly how it works and why EngineerPrep uses it at the core of its question search.
Imagine you could describe every question in your database as a point on a map. Questions about similar topics land close together on the map. Questions about totally different topics land far apart. "Explain binary search tree traversal" and "how do trees work in interviews" would end up almost in the same spot — because they're about the same idea. That's the whole concept. A vector is just a list of numbers. Think of it like coordinates — but instead of two numbers for latitude and longitude, you might have 1,536 numbers. Each number captures a small aspect of the meaning of a sentence. An embedding is what you get when you feed a sentence into an AI model and it hands you back that list of numbers. The model is trained so that sentences with similar meanings produce similar lists of numbers. Vector similarity is then a way to measure how close two of those lists are to each other…
Step 1 — The map starts empty. Picture a blank 2D map (in reality it has hundreds or thousands of dimensions, but two is enough to see what's happening). Every point on this map is a possible meaning. --- Step 2 — Questions get placed on the map. We feed three questions into an embedding model: - "Explain binary search tree traversal" → lands at roughly (0.8, 0.6) - "What is a linked list?" → lands at roughly (0.7, 0.5) - "How does TCP handshaking work?" → lands at roughly (−0.9, 0.2) The first two are both about data structures, so they land close together in the upper-right area. The networking question lands far away on the left. --- Step 3 — A search query arrives. A learner types: "how do trees work in interviews." We feed this query into the same embedding model. It lands at roughly (0.75, 0.55) — right next to "Explain binary search tree traversal." --- Step 4…