Skip to main content

Vector Queries in Azure AI Search

Vector queries find semantically similar content using numeric embeddings and nearest neighbor algorithms.

Prerequisites

  • Vector index with vector fields
  • Embedding model (Azure OpenAI, etc.)
  • Optional: Vectorizer for query-time conversion

Basic Vector Query

Parameters:
  • kind: “vector” for embedding arrays
  • vector: Query embedding (same dimensions as field)
  • fields: Vector field(s) to search
  • k: Number of nearest neighbors to return

Generate Query Embeddings

Azure OpenAI

Response:

Use Same Model

Always use the same embedding model for indexing and querying. Mixing models produces poor results.

Integrated Vectorization

Let Azure AI Search handle vectorization:

Configure Vectorizer

Query with Text

Benefits:
  • No manual embedding generation
  • Consistent model usage
  • Simplified queries

Multiple Vector Fields

Search across multiple vector fields:
All fields must use embeddings from the same model and have the same dimensions.

Multiple Vector Queries

Execute multiple vector queries in parallel:
Use case: Multimodal search with CLIP embeddings Results merged using Reciprocal Rank Fusion (RRF).

Vector Weighting

Adjust relative importance:
Default weight: 1.0

Filtering Vector Results

Apply filters to vector queries:

Filter Modes

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

Exhaustive KNN

Force exact search instead of approximate:
Use when:
  • Maximum accuracy required
  • Small dataset
  • Willing to accept slower queries

Threshold Filtering (Preview)

Exclude low-similarity results:
Effect: Returns fewer than k results if similarities below 0.8

Query Response

Score interpretation:
  • Higher score = more similar
  • Range depends on similarity metric
  • Cosine: -1 to 1 (1 = identical)

Oversampling

Request more candidates for reranking:
Effect: Retrieves k × oversampling candidates, reranks with uncompressed vectors, returns top k

Hybrid Vector + Text

Combine for best results:
Benefits:
  • Keyword precision + semantic recall
  • RRF fusion
  • Better than either alone

Performance Optimization

  • Request only needed results
  • Typical: k=10-50
  • Larger k = slower queries
  • Enable scalar/binary quantization
  • 75-96% size reduction
  • Minimal accuracy loss with rescoring
  • Adjust efSearch for accuracy vs speed
  • Higher efSearch = more accurate, slower
  • Default 500 works for most cases
  • Reduces search space
  • Faster than post-filtering
  • Better for selective filters

Common Patterns

Document Similarity

Troubleshooting

Low Quality Results

  • Verify same embedding model for index and query
  • Check vector dimensions match
  • Ensure sufficient k value
  • Consider hybrid search instead

Slow Queries

  • Reduce k value
  • Enable compression
  • Use preFilter instead of postFilter
  • Tune HNSW efSearch parameter

No Results

  • Check filter conditions
  • Verify vector field name
  • Ensure index has vector data
  • Remove threshold if set too high

Next Steps

Create Vector Index

Build a vector-enabled index

Hybrid Search

Combine with keyword search

Generate Embeddings

Create embeddings from content