Course contentsShow
← AI Engineering
Lesson 269 of 1,8867. Vector Databases - FundamentalsFree lesson

Multi-Vector Queries and Aggregation

Searching with multiple query vectors and combining results effectively.

Multi-Vector Queries and Aggregation

What you'll learn: How to search using multiple query vectors at once and intelligently combine their results for richer retrieval.

The Core Idea

So far, you've learned to search with a single query vector—one question, one embedding, one set of results. But what if your user asks something complex that touches multiple concepts? Or what if you want to find documents relevant to several ideas simultaneously?

Multi-vector queries let you submit multiple query vectors to your vector database in a single search operation, then aggregate (combine) the results intelligently. Think of it like asking a librarian: "Find me books about both machine learning and ethics and healthcare"—you're casting a wider, more nuanced net.

Why This Matters

Some scenarios naturally require multiple perspectives:

  • Hybrid queries: Combining a user's question with their profile/preferences (two vectors)
  • Multi-aspect search: "Find documents covering topic A, B, and C"
  • Query expansion: Generating multiple paraphrases of a query as vectors to capture different phrasings

Aggregation Strategies

Once you have results from multiple vectors, you need to combine them:

  1. Union (OR logic): Merge all result sets, useful when any query vector matching is acceptable
  2. Weighted average: Score each result by averaging its distances across all query vectors—finds items relevant to the overall query set
  3. Min/Max aggregation: Take the closest (min) or most diverse (max) distance per result
  4. Intersection (AND logic): Only return results appearing in all query result sets

The choice depends on whether you want breadth (union) or precision (intersection/weighted scoring).

Key Takeaway: Multi-vector queries let you search with multiple embeddings simultaneously and aggregate results using strategies like union, weighted averaging, or intersection—enabling more sophisticated retrieval that captures complex, multi-faceted information needs.