Back to blog
AI Development Embeddings pgvector PostgreSQL RAG Semantic Search OpenAI

Embeddings and pgvector, Explained With a Real Example

By Ken B Portfolio · Published on October 27, 2026
Illustration of a developer working at a laptop

Your users rarely type the words your data uses. Someone asks to “speed up our ecommerce site”, and the answer is filed under “Make my Shopify store load faster”. The two mean the same thing but share almost no words, so a keyword search finds nothing.

Search by meaning fixes that. It is built on embeddings, and it can live in the Postgres database you already run.

A real case: proposal tips from a freelancer’s own wins

A job-alert app I built for freelancers helps them write proposals. When a new job comes in, it finds the five past proposals closest to it in meaning, each marked won, replied or sent. An AI reads those five and writes a short list of tips, with a note on how sure the advice is.

With keyword search, the two store-speed jobs above look unrelated, and the AI has no history to learn from. With search by meaning, they match. So the tips come from the freelancer’s own history with jobs like this one, not from general advice anyone could get.

An embedding, in plain words

Imagine scoring every job on three things, from 0 to 1: how much it is about online stores, about speed, and about design.

JobOnline storeSpeedDesign
Make my Shopify store load faster0.90.90.1
Speed up our ecommerce site0.80.90.2
Design a logo for my bakery0.10.00.9

The first two rows look alike even though the words don’t. The third looks nothing like them. That is the whole idea: similar meaning gives similar numbers.

A real embedding works the same way, with two differences:

  • It has far more numbers. The model I use, OpenAI’s text-embedding-3-small, gives 1,536 for every piece of text.
  • Nobody chooses what each number means. The model learned them by reading a huge amount of text. You only ever compare whole lists.

Four choices that decide if it works

1. What you turn into numbers decides what “similar” means. For each past proposal I embed one block of text: the job title, the job description, the proposal that was sent, the notes saved with it, and what happened to it. So “similar” means “a similar job, answered in a similar way”. If I only embedded job titles, two very different jobs both called “Website help” would look like twins.

2. One model on both sides. The stored items and the new search must be turned into numbers by the same model. Numbers from two models are like two maps drawn at different scales: you can’t measure a distance across them. Models get replaced every year or so, so I store the numbers per model. A new model can be built next to the old one, compared on real proposals, and switched on with nothing going offline.

3. The same access rules as any other search. Each user only ever searches their own proposals. Search by meaning is not a back door around who can see what. More on that: Row-level security in Postgres: when to turn it on.

4. Keep it fresh. A stored embedding is a snapshot. When a proposal changes, for example a client replies or the job is won, its text is rebuilt and turned into numbers again. If that step fails, it is recorded and a nightly job retries it, so the search never quietly drifts away from the real data.

When to skip it

  • Exact facts. “Jobs over $5,000” or “job ID 12345” are filters, not meaning. Normal search does those, next to the meaning search.
  • Telling good from bad. Embeddings find what is about the same thing, not what is right. A similar proposal can be a losing one. That is why each match carries its outcome.
  • Very short text. One or two words give the model little to go on, and the matches get noisy.

What to ask your developer

  • What text gets turned into numbers for each item, and why that text?
  • What happens when the embedding model is replaced?
  • Can one customer’s search ever return another customer’s data?
  • When a record changes, how is it updated, and what happens if that fails?

If your users search help articles, past tickets, products or documents, search by meaning finds what they mean, not just the words they typed. For the other AI features I build, see What I Can Build With AI.

You don’t need to know how any of this works inside. I choose what gets embedded, keep it in the database you already run, and make sure each user only searches their own data. The code is in the Technical tab.

The short version

Search by meaning turns text into numbers, so similar meaning gives similar numbers. Choose carefully what you embed, use one model on both sides, keep each user’s search to their own data, and update the numbers when records change. With pgvector, it lives in the Postgres database you already run.

What do your users search for that your app can’t find today?

SEARCHBYMEANING

Tell me what your users need to find and I'll tell you how search by meaning would work on your data.

More Posts

All posts