GuidesAI and e-commerce

Semantic search for an online store

By the Banzai Labs teamUpdated on 2 min read

light dress for a summer weddingKeywordsdressweddingsummer0 results for “light”MeaningSearch understands intent, not just words
Keyword search fails where meaning-based search finds the right products.

Keywords or meaning

Two ways to read a query
Keywords
  • Finds “dress” and “wedding”
  • Excellent for a brand or a reference
  • Misses synonyms and intent
Meaning
  • Understands “light” and “summer”
  • Finds products described differently
  • Less precise on a product code

The architecture

  1. 1Product pagesTitle, description, material, uses.
  2. 2EmbeddingsOne vector per product, recomputed on every change.
  3. 3Hybrid searchKeyword and meaning rankings merged.
  4. 4FiltersPrice, size, stock, applied before display.

With PostgreSQL

SELECT id, title
FROM products
WHERE in_stock AND price <= 120
ORDER BY embedding <=> $1   -- query vector
LIMIT 24;

The pgvector extension stores vectors next to the product data; PostgreSQL full-text search provides the keyword ranking.

What to measure

Metric What it tells you
Zero-result searches Gaps in the catalogue or the search
Clicks on top results How relevant the ranking is
Sales after search The real value

The technical base: RAG with PostgreSQL and pgvector. Vectors: vector databases explained.

Frequently asked questions

Should I drop keyword search?
No. A product reference or a brand is better found by keywords. Hybrid search combines both rankings.
Doesn't Shopify already do this?
Shopify's search keeps improving and apps add meaning-based search. Custom work makes sense for a special catalogue or a headless store.
How do I know it works?
Track the zero-result rate, the click rate on results and sales that follow a search, before and after.

Read next

All guides