Skip to main content

Hybrid Search in Azure AI Search

Hybrid search combines the strengths of vector search and keyword search in a single query request, providing better results than either method alone. Hybrid search executes both full-text and vector queries simultaneously, then merges results using Reciprocal Rank Fusion (RRF).

Vector Search

Finds semantically similar content regardless of exact keywords

Keyword Search

Finds exact matches with precision on names, codes, dates

Complementary Strengths

  • Vector search: High recall, semantic understanding
  • Keyword search: High precision, exact matches
  • Combined: Best of both worlds

Benchmark Results

Hybrid search with semantic ranker offers significant improvements in search relevance over either method alone.

How Hybrid Search Works

Query Execution

  1. Parallel execution: Full-text and vector queries run simultaneously
  2. Independent ranking: Each query uses its own ranking algorithm
  3. Result fusion: RRF merges and reranks all results
  4. Single response: Unified result set returned to client

Hybrid Query Structure

{
  "count": true,
  "search": "luxury beachfront hotel",
  "select": "hotelName, description, rating",
  "filter": "rating ge 4.5",
  "vectorQueries": [
    {
      "kind": "vector",
      "vector": [-0.009, 0.018, ...],
      "fields": "descriptionVector",
      "k": 50
    }
  ],
  "top": 10
}
Key components:
  • search: Full-text query string
  • vectorQueries: One or more vector queries
  • filter: Apply to both queries
  • top: Final result count after fusion

Reciprocal Rank Fusion (RRF)

RRF combines multiple result sets by:
RRF_score(d) = Σ 1 / (k + rank_i(d))
Where:
  • d = document
  • k = constant (typically 60)
  • rank_i(d) = rank of document in result set i

Example Fusion

Text results:
  1. Doc A (score: 10.5)
  2. Doc B (score: 8.2)
  3. Doc C (score: 6.1)
Vector results:
  1. Doc C (score: 0.89)
  2. Doc A (score: 0.85)
  3. Doc D (score: 0.82)
RRF scores:
  • Doc A: 1/61 + 1/61 = 0.0328
  • Doc C: 1/63 + 1/61 = 0.0323
  • Doc B: 1/62 + 0 = 0.0161
  • Doc D: 0 + 1/63 = 0.0159
Final ranking: A, C, B, D

With Semantic Ranking

Add semantic ranking for even better results:
{
  "search": "luxury hotel near beach",
  "queryType": "semantic",
  "semanticConfiguration": "my-semantic-config",
  "queryLanguage": "en-us",
  "vectorQueries": [
    {
      "kind": "vector",
      "vector": [...],
      "fields": "descriptionVector",
      "k": 50
    }
  ]
}
Processing order:
  1. Execute full-text and vector queries
  2. Apply filters
  3. Merge with RRF
  4. Semantic reranking on top 50 results
  5. Return top results
Filters apply to both query types:
{
  "search": "conference hotel",
  "filter": "meetingRooms gt 5 and parkingIncluded eq true",
  "vectorFilterMode": "postFilter",
  "vectorQueries": [
    {
      "kind": "vector",
      "vector": [...],
      "fields": "descriptionVector",
      "k": 50
    }
  ]
}

Filter Modes

  • preFilter: Apply before vector search (faster, fewer candidates)
  • postFilter: Apply after vector search (more candidates, slower)

Multiple Vector Queries

Search multiple vector fields:
{
  "search": "thriller mystery novel",
  "vectorQueries": [
    {
      "kind": "vector",
      "vector": [...],
      "fields": "descriptionVector",
      "k": 50,
      "weight": 2.0
    },
    {
      "kind": "vector",
      "vector": [...],
      "fields": "synopsisVector",
      "k": 50,
      "weight": 1.0
    }
  ]
}
Vector weighting: Adjust relative importance of each vector query

Use Cases

  • Keywords: Technical terms, acronyms
  • Vectors: Conceptual similarity
  • Result: Exact terminology + related concepts

Best Practices

Set k=50

For semantic ranker, use k=50 to provide sufficient input

Use Filters

Pre-filter to reduce search scope and improve performance

Test Weights

Experiment with vector weights to optimize for your data

Monitor Performance

Track query latency and result quality metrics

Next Steps

Vector Search

Learn about vector search concepts

Full-Text Search

Master keyword query syntax

Semantic Ranking

Add ML-based reranking