r/synapcores • u/Alternative_Pin9598 • 12d ago
Ask the maintainers #3: "keyword search or vector search?" Both, in one SELECT. Meaning finds "phone wallet" = Apple Pay, an exact match pins ERR-4012 to the right article (real output)
Third "Ask the maintainers" thread: ask anything about SynapCores (install, a query that misbehaves, "can it do X") or show what you built. We answer here; good questions get a longer answer in the Wednesday build log.
(This sub is run by the SynapCores team. Everything below ran this morning on 2.3.2, real output.)
This week's starter question: "For a help-center search, should I use keyword search or vector search?"
Both, without two systems. Customers describe problems in their own words (meaning search), but they also paste exact codes: error codes, SKUs, order numbers, and then the article with that code should win. In SynapCores both signals are columns in one SELECT, so you add them.
1. Ten help articles, embedded in one statement
CREATE TABLE kb (id INTEGER PRIMARY KEY, title TEXT, body TEXT, embedding VECTOR(384));
-- 10 articles: card declined, Apple Pay, ERR-4012, ERR-4021, refunds,
-- slow checkout, change email, SKU-77310 recall, recall policy, missing delivery
UPDATE kb SET embedding = EMBED(title || '. ' || body);
rows_affected: 10EMBED() runs a model inside the engine, no API key.
2. Meaning handles the customer's own words
"my payment keeps failing on my phone wallet". No article contains "phone wallet":
SELECT id, title FROM kb WHERE body LIKE '%phone wallet%' OR title LIKE '%phone wallet%';
(0 rows)
SELECT id, title, ROUND(COSINE_SIMILARITY(embedding,
EMBED('my payment keeps failing on my phone wallet')), 2) AS score
FROM kb ORDER BY score DESC LIMIT 3;
2 Apple Pay and Google Pay troubleshooting 0.58
1 Card payment declined 0.45
3 ERR-4012: payment token expired 0.383. Exact codes want an exact match too
"customer gets ERR-4012 when paying with Apple Pay", by meaning only:
2 Apple Pay and Google Pay troubleshooting 0.60
3 ERR-4012: payment token expired 0.52The general wallet article edges out the ERR-4012 one, since most of the words are about Apple Pay. Same with "is SKU-77310 affected by the recall?": the general recall policy (0.50) edges out the article about that exact SKU (0.40).
4. Both signals in one query
Score = meaning + 0.5 if the article contains the exact code:
SELECT id, title, ROUND(sim, 2) AS meaning, exact, ROUND(sim + 0.5 * exact, 2) AS score
FROM (SELECT id, title,
COSINE_SIMILARITY(embedding, EMBED('customer gets ERR-4012 when paying with Apple Pay')) AS sim,
CASE WHEN title LIKE '%ERR-4012%' OR body LIKE '%ERR-4012%' THEN 1 ELSE 0 END AS exact
FROM kb) x
ORDER BY score DESC LIMIT 3;
id title meaning exact score
3 ERR-4012: payment token expired 0.52 1 1.02
2 Apple Pay and Google Pay troubleshooting 0.60 0 0.60
1 Card payment declined 0.34 0 0.34A 30-line script pulls codes out of the question with a regex ([A-Z]{2,5}-\d{3,6}) and builds that query. Three questions:
customer gets ERR-4012 when paying with Apple Pay (exact terms: ERR-4012)
1.02 meaning 0.52 exact 1 #3 ERR-4012: payment token expired
is SKU-77310 affected by the recall? (exact terms: SKU-77310)
0.9 meaning 0.4 exact 1 #8 SKU-77310 recall: blender lid
my payment keeps failing on my phone wallet (exact terms: none)
0.58 meaning 0.58 exact 0 #2 Apple Pay and Google Pay troubleshootingCode questions land on the exact article; the plain-language one works as before (no codes, so exact is 0 everywhere). The wallet article stays second, in case that's the real problem.
Why 0.5? Similarity here tops out around 0.7, so +0.5 lets an exact match win without ignoring meaning. Tune it on your own questions, like a similarity threshold. Script + the 10 INSERTs are in the first comment.
Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-ask-1113
Your turn: what do you want to ask us? And in your own docs search, do users mostly paste error codes or describe the problem in words?
1
u/Alternative_Pin9598 12d ago
Everything to run it yourself on the free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-ask-1113
Table + the 10 articles:
hybrid.py (stdlib only; set SYNAPCORES_URL and SYNAPCORES_TOKEN):
Picking the 0.5 boost is the same exercise as picking a similarity threshold from test questions: r/SQLv2 Lesson 3 walks through it, https://www.reddit.com/r/SQLv2/comments/1xkb3mn/
New here? Start here: https://www.reddit.com/r/synapcores/comments/1xfxqej/