Part 5: Advanced Queries and Hybrid Search

← Part 4: TypeScript Implementation | Part 6: Performance Optimization β†’

The E-commerce Search That Lost $80K

I was running an e-commerce product search with pure vector similarity. It worked beautifully for semantic matching, but we had a problem:

User searches: "red nike shoes under $100"

Vector search returned:

  1. Nike Air Max 270 Black - $189

  2. Adidas Ultraboost Red - $180

  3. Nike React Blue - $95

Zero of the top 3 results matched the criteria. The results were semantically similar to "shoes," but ignored:

  • Color: red βœ—

  • Brand: nike βœ— (Adidas came up)

  • Price: under $100 βœ—

Conversion rate on filtered searches: 1.2% (terrible)

The fix: Hybrid search combining vector similarity WITH traditional filters.

After implementing:

// Hybrid: Vector similarity + exact filters
const results = searchProducts("red nike shoes under $100", {
  filters: {
    brand: "Nike",
    color: "red",
    maxPrice: 100,
  },
});

Conversion rate: 1.2% β†’ 11.8%. Revenue from search: +$80k/month.

This article shows you how to build advanced queries that combine the best of both worlds.

Vector Search Alone

Pros:

  • βœ… Understands meaning

  • βœ… Finds semantically similar items

  • βœ… Works with natural language

Cons:

  • ❌ Can't enforce exact constraints

  • ❌ Ignores critical filters (price, category, availability)

  • ❌ No relevance boosting

Traditional Search Alone

Pros:

  • βœ… Exact filters work perfectly

  • βœ… Predictable results

  • βœ… Fast with proper indexes

Cons:

  • ❌ Keyword matching only

  • ❌ Misses semantically similar items

  • ❌ User must use exact words

Solution: Hybrid search combining both.

Hybrid Search: Vector + Filters

Usage Example

Reranking for Better Results

After getting initial results from vector search, rerank them using additional signals:

Multi-Vector Queries

Search across multiple vector columns (e.g., product name + description + reviews).

Query Expansion

Expand user queries to find more relevant results:

Faceted Search with Vectors

Combine faceted filtering with vector search:

Customize search results based on user preferences:

Filtering Vector Results Post-Search

Sometimes it's better to filter after vector search:

When to use post-filtering:

  • Filters are very selective (would eliminate most vectors)

  • You want maximum semantic relevance first

  • Number of candidates is manageable

When to use pre-filtering:

  • Filters significantly reduce candidate set

  • Database indexes can accelerate filtering

  • Memory constraints

Complete Advanced Search API

What's Next

In this article, you learned:

  • βœ… Hybrid search combining vectors + filters + keywords

  • βœ… Reranking with multiple signals

  • βœ… Multi-vector queries

  • βœ… Query expansion for better recall

  • βœ… Faceted search

  • βœ… Personalized search

  • βœ… When to filter before vs after vector search

Next: Production best practices including index optimization, caching strategies, and monitoring.


← Part 4: TypeScript Implementation | Part 6: Performance Optimization β†’

Last updated