The problem: a customer types "my internet connection drops every few minutes" into your help center's search box. You have an article that answers it, called "My Wi-Fi keeps disconnecting". The search returns nothing, because the two sentences don't share a single word. The customer opens a ticket.
We build SynapCores, and the last part of this page runs in it. Everything before that is plain SQL run on SQLite, plus Postgres and MySQL equivalents, so you can follow it without installing anything of ours.
Searching by meaning instead of keywords: semantic search vs keyword search
There are three levels of "find the right row":
| Matches | Finds "disconnects" for "disconnecting" | Finds "Wi-Fi keeps disconnecting" for "internet connection drops" | |
|---|---|---|---|
LIKE '%word%' |
an exact substring | No | No |
| Full-text search | words and their stems, ranked | Yes | No |
| Semantic search | meaning, as an embedding | Yes | Yes |
Semantic search turns every piece of text into an embedding: a list of a few hundred numbers produced by a small model, arranged so that texts with similar meanings get similar numbers. You compute one for each row, and one for the query, then sort rows by how close they are. Closeness is usually cosine similarity: 1.0 means the same direction, values near 0 mean unrelated.
Keyword search is not the loser in this table. It's exact, cheap and easy to explain. You'll see below that it beats meaning on error codes, and that the best setup usually uses both.
When this is useful
- People search in their own words: a help center, an internal wiki, support tickets, product reviews, policies.
- The same thing has many names ("cancel", "unsubscribe", "stop paying", "close my account").
- You want "related articles" or "similar tickets" without hand-written synonym lists.
- You're building a rag chatbot and need to find the passages to give the model. That step is semantic search.
The data
Nine help-center articles, each with a category and a last-updated date. They're the six from our r/SQLv2 Lesson 1 plus three more: a double charge, a refund policy, and an error code.
CREATE TABLE help_articles (
id INTEGER PRIMARY KEY,
category TEXT,
updated_on TEXT,
title TEXT,
body TEXT
);
INSERT INTO help_articles (id, category, updated_on, title, body) VALUES
(1, 'account', '2026-03-02', 'How do I reset my password?', 'Use "Forgot password" on the login page. The reset link expires after one hour.'),
(2, 'connectivity', '2026-09-14', 'My Wi-Fi keeps disconnecting', 'Move the router away from the microwave and update its firmware.'),
(3, 'billing', '2025-11-20', 'How can I change my billing address?', 'Settings > Billing > Edit address.'),
(4, 'app', '2026-08-01', 'The app crashes when I open it', 'Update to the latest version, then clear the app cache.'),
(5, 'data', '2026-01-10', 'Can I export my data to CSV?', 'Yes: Reports > Export > CSV.'),
(6, 'billing', '2026-07-22', 'How do I cancel my subscription?', 'Settings > Plan > Cancel. You keep access until the period ends.'),
(7, 'billing', '2026-10-03', 'Why was I charged twice?', 'A second charge is usually a pending authorisation. It drops off within 5 business days.'),
(8, 'billing', '2024-06-30', 'How do I get a refund?', 'Refunds are issued to the original card within 30 days of purchase.'),
(9, 'account', '2026-05-18', 'Error E-4012 when signing in', 'E-4012 means your single sign-on session expired. Sign out of your identity provider and sign in again.');
Sections 1 and 2 were run on SQLite 3.43.2 (macOS), and the outputs are pasted from that run. The Postgres and MySQL versions are shown for reference; we haven't run them.
1. LIKE: the exact substring
SELECT id, title FROM help_articles
WHERE title LIKE '%internet%' OR body LIKE '%internet%';
(0 rows)
No article contains "internet". That's expected. The less obvious failure is a word in a different form:
SELECT id, title FROM help_articles
WHERE title LIKE '%disconnects%' OR body LIKE '%disconnects%';
(0 rows)
"disconnects" isn't a substring of "disconnecting". LIKE also can't rank: a row matches or it doesn't. And a leading % means the database can't use an ordinary index, so it reads every row.
2. Full-text search: words, stems and a ranking
Full-text search splits text into words, reduces each word to its stem ("disconnecting" and "disconnects" both become "disconnect"), indexes them, and ranks matches. SQLite has it built in as FTS5:
CREATE VIRTUAL TABLE help_fts USING fts5(
title, body,
content='help_articles', content_rowid='id',
tokenize='porter'
);
INSERT INTO help_fts(help_fts) VALUES ('rebuild');
SELECT a.id, a.title, ROUND(bm25(help_fts), 2) AS bm25
FROM help_fts JOIN help_articles a ON a.id = help_fts.rowid
WHERE help_fts MATCH 'router disconnects'
ORDER BY bm25;
id title bm25
-- ---------------------------- -----
2 My Wi-Fi keeps disconnecting -3.56
Stemming fixed the word-form problem. (bm25() in SQLite is negative, and lower is better, so ORDER BY bm25 puts the best match first.)
It also finds exact codes, which matters later:
SELECT a.id, a.title, ROUND(bm25(help_fts), 2) AS bm25
FROM help_fts JOIN help_articles a ON a.id = help_fts.rowid
WHERE help_fts MATCH '"E-4012"'
ORDER BY bm25;
id title bm25
-- ---------------------------- -----
9 Error E-4012 when signing in -2.11
Now the customer's actual sentence. By default, FTS5 requires every word:
SELECT a.id, a.title
FROM help_fts JOIN help_articles a ON a.id = help_fts.rowid
WHERE help_fts MATCH 'internet connection drops';
(0 rows)
Loosen it to any word, and you get an answer. The wrong one:
SELECT a.id, a.title, ROUND(bm25(help_fts), 2) AS bm25
FROM help_fts JOIN help_articles a ON a.id = help_fts.rowid
WHERE help_fts MATCH 'internet OR connection OR drops'
ORDER BY bm25;
id title bm25
-- ------------------------ -----
7 Why was I charged twice? -1.62
"A pending authorisation … drops off within 5 business days." The word matched; the meaning didn't. The same thing happens with "stop paying": zero rows, because no article uses either word. Full-text search knows words, not what they're about.
Full-text search does combine cleanly with filters, which is the other half of real search:
SELECT a.id, a.category, a.updated_on, a.title
FROM help_fts JOIN help_articles a ON a.id = help_fts.rowid
WHERE help_fts MATCH 'charge OR refund'
AND a.category = 'billing'
AND a.updated_on >= '2026-01-01';
id category updated_on title
-- -------- ---------- ------------------------
7 billing 2026-10-03 Why was I charged twice?
The refund article matched "refund" but was dropped by the date filter, because it was last updated in 2024.
In Postgres (not run here), the same idea is a tsvector column with a GIN index:
ALTER TABLE help_articles
ADD COLUMN tsv tsvector
GENERATED ALWAYS AS (to_tsvector('english', title || ' ' || body)) STORED;
CREATE INDEX help_articles_tsv ON help_articles USING GIN (tsv);
SELECT id, title, ts_rank(tsv, q) AS rank
FROM help_articles, websearch_to_tsquery('english', 'router disconnects') AS q
WHERE tsv @@ q
ORDER BY rank DESC;
In MySQL (not run here), it's a FULLTEXT index and MATCH … AGAINST. MySQL doesn't stem words, so "disconnects" won't match "disconnecting" there:
ALTER TABLE help_articles ADD FULLTEXT ft_help (title, body);
SELECT id, title,
MATCH(title, body) AGAINST ('router disconnects' IN NATURAL LANGUAGE MODE) AS score
FROM help_articles
WHERE MATCH(title, body) AGAINST ('router disconnects' IN NATURAL LANGUAGE MODE)
ORDER BY score DESC;
If your users search with the words your articles use, stop here. Postgres full-text search, with a synonym list for the handful of terms people mix up, is a good search box, and you already run it.
3. Search by meaning: embeddings and cosine similarity
Semantic search needs three things:
- An embedding model. A small one is enough for search. Common choices output 384 or 768 numbers per text.
- A vector column on each row, holding the embedding of that row's text. Embed the title and body together; a title alone often carries too little meaning.
- A query that embeds the search text with the same model and sorts rows by similarity.
The design choice is where the embedding is computed, because that decides how many systems you run and whether your filters live next to your vectors. There are three common answers.
Postgres + pgvector (not run here). The database stores and compares vectors; your application computes them, with a local library such as sentence-transformers or a hosted embeddings API:
CREATE EXTENSION IF NOT EXISTS vector;
ALTER TABLE help_articles ADD COLUMN embedding vector(384);
-- your app: for each row, embedding = model.encode(title + '. ' + body), then UPDATE
-- $1 is the query's embedding, computed by your app with the same model
SELECT id, title, 1 - (embedding <=> $1) AS similarity
FROM help_articles
WHERE category = 'billing'
ORDER BY embedding <=> $1
LIMIT 3;
CREATE INDEX ON help_articles USING hnsw (embedding vector_cosine_ops);
This is a strong, common setup. Two things to plan for: the app has to re-embed a row whenever its text changes, and with an approximate index plus a selective WHERE, the index can hand back fewer than LIMIT rows (recent pgvector versions add iterative index scans for this; check the docs for your version).
A dedicated vector database (Pinecone, Qdrant, Weaviate, Milvus and others). Vectors and a copy of the metadata you filter on live in a separate service built for large vector workloads. You keep it in sync with your main database, and you join its results back to your rows in application code.
Embeddings computed in the database (SynapCores, below). The model runs inside the engine, so EMBED('the query') is a SQL expression. The row text, the embedding, the filters and the similarity are in one statement, and nothing is sent to an external embedding service.
How the options compare
| LIKE | Full-text (Postgres tsvector, MySQL FULLTEXT, SQLite FTS5) |
Postgres + pgvector | Dedicated vector DB | EMBED in the database (SynapCores) | |
|---|---|---|---|---|---|
| Finds paraphrases ("stop paying" → cancel) | No | No | Yes | Yes | Yes |
| Exact codes, SKUs, names | Yes | Yes | Weak | Weak | Weak: can't tell close codes apart (use a keyword predicate, below) |
| Who computes embeddings | n/a | n/a | Your app or an API | Your app or an API | The database |
| Filters on your columns | Same query | Same query | Same query | Metadata copied into the vector DB | Same query |
| Systems to keep in sync | 1 | 1 | 1 database + an embedding step | 2 + an embedding step | 1 |
| Approximate vector index | n/a | n/a | Yes (HNSW, IVFFlat) | Yes | HNSW on SQL vector columns (IVFFlat is refused). Used only for an unfiltered ORDER BY COSINE_SIMILARITY(...) LIMIT n; the score-alias form and filtered queries scan the table |
| Explains why a row matched | The word is there | The words are there | A score | A score | A score |
When full-text search is enough: your users and your documents use the same vocabulary, or a short synonym list covers the gap. It's in the database you already run, and it explains itself.
When pgvector is enough: you're on Postgres, you're fine adding an embedding step to your write path, and you want a mature approximate index. For most teams that already run Postgres, this is the default answer, and nothing on this page argues against it.
When a dedicated vector database is worth it: vectors are the main workload, the corpus is very large, and a separate service with its own scaling is easier for you than tuning Postgres.
What in-database EMBED changes is where the embedding step lives, not what similarity can find. There's no embedding job to run or keep in sync, and the query is plain SQL. We haven't benchmarked it against pgvector or any vector database, and this page makes no claim that it's faster or more accurate.
Hybrid search: keywords plus meaning plus filters
Real search boxes get both kinds of query. "I want to stop paying" needs meaning. "E-4012" needs the exact token: to an embedding model, E-4012 and E-4013 look almost the same, so meaning alone can't tell a code you have from one you don't. And almost every query has filters that aren't text at all: this customer's plan, this tenant, published, updated in the last year.
Hybrid search runs a keyword score and a meaning score for the same query and merges them, inside the filters. Two common ways to merge:
- Reciprocal rank fusion (RRF). Take the keyword ranking and the meaning ranking, give each row
1 / (60 + rank)from each list, and add them. It needs no tuning, because it ignores the raw scores, which aren't comparable between BM25 and cosine similarity. 60 is the constant commonly used with RRF. - A weighted sum. Add a fixed boost to the similarity when an exact keyword matches. Simpler, but the weight is a judgement call you should test on real queries.
Whichever you pick, apply the structured filters before ranking, not after. If you rank the top 10 by meaning and then drop the stale or wrong-tenant ones, you can end up with 2 results, or none.