Azure AI Search vector store
The AzureAISearchVector class provides vector search using Azure AI Search, Microsoft's cloud search service with native vector search support. It offers metadata filtering, hybrid (vector + text) search, and semantic ranking on top of an existing Azure AI Search resource.
Constructor optionsDirect link to Constructor options
id:
endpoint:
credential:
apiVersion?:
clientOptions?:
autoIndexMetadata?:
import { AzureAISearchVector } from '@mastra/azure-ai-search'
const vectorStore = new AzureAISearchVector({
id: 'azure-search-vectors',
endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT!,
credential: process.env.AZURE_AI_SEARCH_CREDENTIAL!,
})
MethodsDirect link to Methods
createIndex()Direct link to createindex
indexName:
dimension:
metric?:
metadataIndexes?:
For Azure AI Search-specific index features (custom vector field name, additional schema fields, HNSW parameters, semantic configuration), use createAdvancedIndex() with AzureAISearchCreateIndexParams.
upsert()Direct link to upsert
indexName:
vectors:
metadata?:
ids?:
deleteFilter?:
query()Direct link to query
indexName:
queryVector:
topK?:
filter?:
includeVector?:
Unsupported filter operators (for example $regex, $size, or $all, none of which map to Azure AI Search's OData filter syntax) throw an error rather than being silently dropped from the query.
listIndexes()Direct link to listindexes
Returns an array of index names as strings.
describeIndex()Direct link to describeindex
indexName:
Returns:
interface IndexStats {
dimension: number
count: number
metric: 'cosine' | 'euclidean' | 'dotproduct'
}
deleteIndex()Direct link to deleteindex
indexName:
updateVector()Direct link to updatevector
Update a single vector by ID or by metadata filter. Either id or filter must be provided, but not both.
indexName:
id?:
filter?:
update:
deleteVector()Direct link to deletevector
indexName:
id:
deleteVectors()Direct link to deletevectors
Delete multiple vectors by IDs or by metadata filter. Either ids or filter must be provided, but not both.
indexName:
ids?:
filter?:
Azure-specific query methodsDirect link to Azure-specific query methods
Beyond the standard query() method, AzureAISearchVector exposes Azure AI Search-specific capabilities:
advancedQuery(): exposes Azure AI Search vector query parameters directly, including exhaustive search, query weighting, oversampling, additional vector queries for multi-vector search, pre/post filtering mode, and text-based query types (semantic,hybrid).semanticQuery(): convenience wrapper aroundadvancedQuery()for semantic ranking with a configured semantic configuration.hybridQuery(): convenience wrapper combining vector search with a full-text query.multiVectorQuery(): convenience wrapper for querying against multiple weighted vectors at once.exactQuery(): convenience wrapper foradvancedQuery()with exhaustive (non-approximate) search enabled.
These methods are additive: query() remains the Memory-compatible entry point used by Mastra's semantic recall.
Response typesDirect link to Response types
Query results are returned in this format:
interface QueryResult {
id: string
score: number
metadata: Record<string, any>
vector?: number[] // Only included if includeVector is true
}