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 optionsConstructor 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!,
})
MethodsMethods的直接链接
createIndex()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()upsert的直接链接
indexName:
vectors:
metadata?:
ids?:
deleteFilter?:
query()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()listindexes的直接链接
Returns an array of index names as strings.
describeIndex()describeindex的直接链接
indexName:
Returns:
interface IndexStats {
dimension: number
count: number
metric: 'cosine' | 'euclidean' | 'dotproduct'
}
deleteIndex()deleteindex的直接链接
indexName:
updateVector()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()deletevector的直接链接
indexName:
id:
deleteVectors()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 methodsAzure-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 typesResponse types的直接链接
Query results are returned in this format:
interface QueryResult {
id: string
score: number
metadata: Record<string, any>
document?: string // Matched document content
vector?: number[] // Only included if includeVector is true
}