1. Azure AI Search向量存储核心架构解析
Azure AI Search的向量索引采用分层存储设计,每个索引包含三个关键组成部分:
- 键字段(Key Field):唯一标识文档的字符串类型字段,通常命名为"id"
- 向量字段(Vector Field):存储嵌入向量的Collection(Edm.Single)类型字段
- 元数据字段(Metadata Field):包含原始文本和其他过滤条件的常规字段
典型索引定义示例如下:
json复制{
"name": "vector-index",
"fields": [
{ "name": "id", "type": "Edm.String", "key": true },
{
"name": "content_vector",
"type": "Collection(Edm.Single)",
"searchable": true,
"dimensions": 1536,
"vectorSearchProfile": "myHnswProfile"
},
{ "name": "content", "type": "Edm.String" }
]
}
关键细节:向量字段必须指定dimensions属性,其值需与嵌入模型输出维度严格一致。例如使用text-embedding-ada-002模型时,必须设为1536。
1.1 向量搜索配置详解
向量搜索配置通过vectorSearchProfile关联算法参数:
json复制"vectorSearch": {
"algorithms": [
{
"name": "myHnswConfig",
"kind": "hnsw",
"hnswParameters": {
"m": 4,
"efConstruction": 400,
"efSearch": 500,
"metric": "cosine"
}
}
],
"profiles": [
{
"name"
