Skip to content
Ahmad Raza
Menu
All posts

5 min read

Hybrid Search for Catalog Q&A: Keywords Plus Vectors

Exact SKU lookups need keyword search. Vague gift questions need semantic search. Here is how to combine both, rerank the results, and give your catalog assistant answers that hold up.

Hybrid Search for Catalog Q&A: Keywords Plus Vectors
On this page

Two shoppers type into the same store assistant. One pastes "SKU TR-2207-BLK." The other writes "something cosy for my dad who is always cold, under $60." A pure vector search handles the second one well and fumbles the first. A pure keyword search nails the SKU and returns nothing useful for the dad.

Real catalogs get both kinds of questions all day. That is why most production catalog search ends up hybrid: keyword matching and vector similarity running side by side, with a reranking step that decides what actually gets shown.

Where vector search falls short

Embeddings turn text into points in space so that similar meanings land close together. That is great for "cosy," "warm," and "fleece" being neighbours. It is not great for identifiers.

To an embedding model, "TR-2207-BLK" and "TR-2207-NVY" look almost identical. So do "iPhone 15 case" and "iPhone 16 case." Model numbers, SKUs, sizes, and part codes carry their meaning in exact characters, and embeddings blur exact characters on purpose.

You see the symptoms quickly: the assistant returns the navy variant when the user asked for black, or a case for the wrong phone generation. Each answer looks reasonable, which makes the bug harder to notice.

Where keyword search falls short

Classic keyword search (BM25 in Elasticsearch, OpenSearch, Postgres full text, Typesense, Meilisearch, and others) scores documents by matching terms. It is precise and fast, and it treats "TR-2207-BLK" as exactly that.

But it has no idea that "cosy" relates to "fleece lined" or that "for my dad" hints at men's sizing. Shoppers rarely use your product copy's vocabulary, so keyword search misses a lot of good matches for open ended questions.

Run both, then merge

A hybrid setup sends the query to both engines and combines the ranked lists. The simplest dependable merge is reciprocal rank fusion (RRF): each result gets a score based on its position in each list, and the scores are summed. A product that ranks well in both lists rises to the top. A product that only one engine found still gets a chance.

RRF is popular because it does not require the two engines' scores to be on the same scale. You only use ranks. Many search engines and vector databases now offer hybrid queries with RRF built in, so you may not need to write it yourself.

A typical flow looks like this:

  1. Normalise the query (lowercase, trim, expand common abbreviations).
  2. Run keyword search over title, SKU, brand, tags, and key attributes.
  3. Run vector search over a richer text field: title plus description plus attributes.
  4. Merge with RRF and keep the top 30 to 50.
  5. Rerank those candidates and keep the top 5 to 10 for the assistant.

Route exact identifiers before anything else

Hybrid ranking helps, but some queries should skip ranking entirely. If the query matches a SKU pattern, a barcode, or a product handle, do a direct lookup first. If it finds an exact hit, return that product and stop.

A small regex or a quick check against a SKU index costs almost nothing and removes a whole class of errors. Agents benefit from this too: give them a get_product_by_sku tool next to the general search_products tool, and they will use the precise one when the user is precise.

Filters are not optional

Price limits, sizes, colours, availability, and region should be applied as hard filters, not as words the search engine hopes to match. "Under $60" is a filter on price. "In stock" is a filter on inventory. "Ships to Pakistan" is a filter on shipping eligibility.

Have the agent, or a light parsing step, pull these constraints out of the query and pass them as structured parameters. Then the ranking engines only see the descriptive part ("cosy, for an older man who gets cold"). Results get better and you never show an out of stock or over budget item at the top.

Reranking: the step that makes it feel smart

After merging, you have a few dozen plausible candidates. A reranker reads the query and each candidate together and scores how well they actually match. Cross encoder rerankers and hosted rerank APIs are both common choices. You can also use a small language model with a scoring prompt, though that is slower and costs more per query.

Reranking is where "cosy for my dad" starts preferring a fleece lined flannel shirt over a thin cotton tee, even if both mention "soft." It is also a good place to apply business rules: boost items with good stock, demote ones with frequent returns.

Keep the candidate set small. Reranking 30 items is quick. Reranking 500 is not.

What to index in each engine

A few practical choices make a big difference:

  • Keyword fields: title, SKU, variant SKUs, brand, model number, product type, tags, key attributes like material and size.
  • Vector text: a readable product summary that combines title, short description, main attributes, and use cases. Avoid dumping raw HTML or long legal text into it.
  • Variants: index variant identifiers for keyword search, but embed at the product level. You usually want to find the product first, then pick the right variant.
  • Freshness: price and stock should come from a live catalog call at answer time, not from the search index. Use search to find candidates and the catalog API to confirm the details.

Test with both kinds of queries

Build an evaluation set that deliberately mixes query styles:

  • Exact: SKUs, model numbers, product names copied from the site.
  • Near exact: typos, missing hyphens, colour in a different place.
  • Vague: gift ideas, use cases, "something like X but cheaper."
  • Constrained: price caps, sizes, in stock only.

For each query, list the products that should appear in the top five. Then compare keyword only, vector only, and hybrid with reranking. In most catalogs the hybrid setup wins on the mixed set, but measure it on your own data rather than assuming.

Keep it simple to start

You do not need a custom ranking model on day one. A sensible starting point:

  • One search engine that supports both BM25 and vectors, or one of each.
  • An exact SKU lookup before search.
  • Hard filters for price, size, stock, and region.
  • RRF to merge.
  • An off the shelf reranker on the top 30.

That covers most of what a catalog assistant needs, and every piece is easy to inspect when something goes wrong.

If you want help setting up hybrid search and a catalog agent for a Next.js or Shopify store, I build these systems end to end. Reach out through my contact section or email ahmadraza365pro@gmail.com.

  • 5 min read

    A 30-Day Agentic Commerce Rollout for a Next.js Store

    A practical, week by week plan to make a Next.js store ready for AI shopping agents: clean the data, ship a read only catalog MCP server, add carts, hand off to confirmed checkout, then log and cap everything.

  • 5 min read

    Fraud and Abuse When Agents Shop Your Checkout

    AI shopping agents look a lot like bots, and bots look a lot like agents. Here is how to tell them apart, where to put bot challenges, and why hosted checkout like Shop Pay is your best trust boundary.

  • 4 min read

    Hydrogen SDK vs Calling Storefront API Yourself in 2026

    Shopify's Hydrogen SDK now reaches beyond Remix and React Router into other frameworks. Here is what it gives you for agent ready storefronts, what a thin Next.js client gives you, and when each one pays off.