Skip to main content

Overview

Azure AI Search provides enterprise-grade vector search with hybrid search capabilities, combining vector similarity with full-text search and semantic ranking.

Installation

Basic Usage

Constructor Options

Authentication

string
Azure AI Search endpoint (defaults to AZURE_AI_SEARCH_ENDPOINT env var)
string
Azure AI Search admin key (defaults to AZURE_AI_SEARCH_KEY env var)
AzureKeyCredential | DefaultAzureCredential | ManagedIdentityCredential
Azure credential object (alternative to key)

Index Configuration

string
required
Name of the search index
IndexManagement
default:"NoValidation"
Index validation strategy:
  • IndexManagement.NO_VALIDATION - No validation
  • IndexManagement.VALIDATE_INDEX - Validate index exists
  • IndexManagement.CREATE_IF_NOT_EXISTS - Auto-create index
number
default:1536
Vector embedding dimensions
KnownVectorSearchAlgorithmKind
default:"ExhaustiveKnn"
Vector search algorithm: ExhaustiveKnn or Hnsw
KnownVectorSearchCompressionKind
Vector compression: BinaryQuantization or ScalarQuantization

Field Configuration

string
default:"id"
Field name for document IDs
string
default:"chunk"
Field name for text content
string
default:"embedding"
Field name for embedding vectors
string
default:"metadata"
Field name for metadata JSON string
string
default:"doc_id"
Field name for document reference IDs
string[]
default:[]
List of fields to hide from retrieval results
Array | Map
Metadata fields that can be filtered. Can be:
  • Array of field names: ["author", "category"]
  • Map of field to name: {author: "author", topic: "theme"}
  • Map with types: {author: ["author", MetadataIndexFieldType.STRING]}

Configuration

Environment Variables

Using Azure Identity

Using Managed Identity

Index Management

Auto-Create Index

Vector Algorithm Configuration

Query Modes

Azure AI Search supports multiple query modes:

Vector Search (Default)

Combines vector and full-text search:
Adds semantic ranking to hybrid search:
Full-text search only:

Metadata Filtering

Supported Filter Operators

Azure AI Search supports:
  • EQ - Equal
  • IN - Value in array

Managing Data

Add Documents

Delete by Document ID

Get Nodes

Complete Example

Best Practices

  1. Use HNSW for production: Better performance than exhaustive KNN
  2. Enable compression: Reduce storage costs with quantization
  3. Index only necessary metadata: Minimize index size
  4. Use hybrid search: Combine vector and text for better results
  5. Monitor costs: Track search units and storage usage
  6. Implement retry logic: Handle transient failures
  7. Use managed identity: More secure than API keys

Troubleshooting

Index Not Found

Authentication Failed

Verify your credentials:

Dimension Mismatch

Ensure embedding dimensions match:

See Also