调用PutVectorIndexFusion接口在向量Bucket中创建Fusion模式的向量索引。
Fusion Mode 目前处于邀测阶段,在华南1(深圳)、印度尼西亚(雅加达)地域提供。Standard 模式向量索引的创建请参见 PutVectorIndex。
注意事项
Fusion 模式索引通过 Schema 定义各字段的类型与检索能力,支持向量检索、标量过滤、全文检索等多种检索能力。同一向量Bucket下可同时存在 Standard 模式与 Fusion 模式的索引。
请求中包含服务端不支持的参数时会直接报错。
创建操作只能全部成功或全部失败。
权限说明
阿里云账号默认拥有全部权限。阿里云账号下的RAM用户或RAM角色默认没有任何权限,需要阿里云账号或账号管理员通过RAM Policy概述或Bucket Policy授予操作权限。
API | Action | 说明 |
PutVectorIndexFusion |
| 创建Fusion模式的向量索引。 |
请求语法
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
Content-type: application/json
{
"indexName": "string",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "string",
"type": "string"
}
]
}
}请求头
此接口仅涉及公共请求头。更多信息,请参见公共HTTP头定义。
请求参数
名称 | 数据类型 | 是否必选 | 描述 | 示例值 |
indexName | 字符串 | 是 | 索引名称,用户可自定义。
| vectorindex1 |
mode | 字符串 | 是 | 索引模式,创建Fusion模式索引时取值为 fusion。 | fusion |
schemaConfiguration | 对象 | 是 | Schema 配置的容器。服务端不支持的配置将直接报错。 | - |
fields | 对象数组 | 是 | Schema 字段配置。限制如下:
父节点:schemaConfiguration | - |
fields.name | 字符串 | 是 | 字段名。
父节点:fields | vector_1 |
fields.type | 字符串 | 是 | 字段类型,取值:
父节点:fields | vector |
不同fields.type支持的参数
fields.type | 名称 | 数据类型 | 是否必选 | 默认值 | 描述 |
vector | dataType | 字符串 | 是 | - | 向量数据类型,用户不可选,取值:float32(浮点型)。 |
dimension | 整型 | 是 | - | 向量维度,仅支持 1~4096 维。 | |
distanceMetric | 字符串 | 是 | - | 距离度量函数,取值:
| |
double | isArray | 布尔值 | 否 | false | 是否为数组,数组最大支持 128 个元素。不支持 NaN、正负 Infinity 等值。 |
long | isArray | 布尔值 | 否 | false | 是否为数组,数组最大支持 128 个元素。 |
ip | isArray | 布尔值 | 否 | false | 是否为数组,数组最大支持 128 个元素。 |
string | isArray | 布尔值 | 否 | false | 是否为数组,限制如下:
|
isPartitionKey | 布尔值 | 否 | false | 是否作为分区键。
| |
exactMatch | 布尔值 | 否 | true | 是否支持精确匹配(不分词)的查询能力。例如某字段 field_a 写入 "abcd123",则查询支持 field_a="abcd123" 的过滤能力。开启 exactMatch 后,单个 string 最大 4 KB。默认值与限制如下:
| |
text.enabled | 布尔值 | 否 | false | 是否开启分词。开启分词后可支持全文检索算子。分词能力限制如下:
text 为分词字段的父节点,其下可配置 analyzer、analyzerParameters 等参数。 | |
text.analyzer | 字符串 | 否 | standard | 分词器类型,取值:
|
分词器参数(text.analyzerParameters)
不同分词器支持的参数如下:
standard 分词器:
caseSensitive:是否大小写敏感。默认值 false,此时所有英文字母会转换为小写。如需保持大小写敏感,可设置为 true。delimitWord:对于英文和数字连接在一起的单词,是否分割英文和数字。默认值 false,表示数字和英文不拆分。设置为 true 时,例如 “iphone6” 会被拆分成 “iphone” 和 “6”。
split 分词器:
caseSensitive:同 standard 分词器。delimiter:自定义分隔符,必填,无默认值。可选值:空格字符(" ")、竖划线("|")、短横杠("-")、下划线("_")、英文逗号(",")。
响应头
此接口仅涉及公共响应头。更多信息,请参见公共HTTP头定义。
示例
以下示例中的向量取值与维度仅用于示意结构,实际调用时向量长度必须与建表时声明的 dimension 严格一致,否则会报参数非法。
综合示例(全字段类型)
请求示例
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 01:33:47 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218
Content-type: application/json
{
"indexName": "vectorindex1",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "vector_1",
"type": "vector",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "euclidean"
},
{
"name": "vector_2",
"type": "vector",
"dataType": "float32",
"dimension": 512,
"distanceMetric": "cosine"
},
{
"name": "timestamps",
"type": "long",
"isArray": true
},
{
"name": "price",
"type": "double"
},
{
"name": "ip",
"type": "ip"
},
{
"name": "location",
"type": "geoPoint"
},
{
"name": "tag",
"type": "string"
},
{
"name": "user_id",
"type": "string",
"isPartitionKey": true
},
{
"name": "tags",
"type": "string",
"isArray": true
},
{
"name": "title_1",
"type": "string",
"exactMatch": true,
"text": {
"enabled": true,
"analyzer": "standard",
"analyzerParameters": {
"caseSensitive": true,
"delimitWord": false
}
}
},
{
"name": "title_2",
"type": "string",
"exactMatch": false,
"text": {
"enabled": true,
"analyzer": "split",
"analyzerParameters": {
"caseSensitive": true,
"delimiter": " "
}
}
}
]
}
}返回示例
HTTP/1.1 200 OK
x-oss-request-id: 534B371674E88A4D8906****
Date: Thu, 17 Apr 2025 01:33:47 GMT
Connection: keep-alive
Server: AliyunOSS最小 Schema:单向量字段
请求示例
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 01:33:47 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218
Content-type: application/json
{
"indexName": "docindex",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "content_vector",
"type": "vector",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "cosine"
}
]
}
}多向量:图文视三路多模态
请求示例
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 01:33:47 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218
Content-type: application/json
{
"indexName": "multimodalindex",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "text_vector",
"type": "vector",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "cosine"
},
{
"name": "image_vector",
"type": "vector",
"dataType": "float32",
"dimension": 512,
"distanceMetric": "euclidean"
},
{
"name": "video_vector",
"type": "vector",
"dataType": "float32",
"dimension": 256,
"distanceMetric": "ip"
},
{
"name": "title",
"type": "string",
"exactMatch": true,
"text": {
"enabled": true,
"analyzer": "standard"
}
},
{
"name": "duration",
"type": "long"
}
]
}
}全文检索:standard 标准分词器
请求示例
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 01:33:47 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218
Content-type: application/json
{
"indexName": "kbindex",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "chunk_vector",
"type": "vector",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "cosine"
},
{
"name": "title",
"type": "string",
"exactMatch": true,
"text": {
"enabled": true,
"analyzer": "standard",
"analyzerParameters": {
"caseSensitive": false,
"delimitWord": true
}
}
},
{
"name": "body",
"type": "string",
"exactMatch": false,
"text": {
"enabled": true,
"analyzer": "standard"
}
},
{
"name": "doc_id",
"type": "string"
},
{
"name": "year",
"type": "long"
},
{
"name": "status",
"type": "string"
},
{
"name": "updated_at",
"type": "long"
}
]
}
}分区键:多租户 RAG 知识库
请求示例
POST /?putVectorIndexFusion HTTP/1.1
Host: examplebucket-123***456.cn-hangzhou-internal.oss-vectors.aliyuncs.com
Date: Thu, 17 Apr 2025 01:33:47 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218
Content-type: application/json
{
"indexName": "tenantkbindex",
"mode": "fusion",
"schemaConfiguration": {
"fields": [
{
"name": "chunk_vector",
"type": "vector",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "cosine"
},
{
"name": "tenant_id",
"type": "string",
"isPartitionKey": true
},
{
"name": "doc_id",
"type": "string"
},
{
"name": "content",
"type": "string",
"exactMatch": false,
"text": {
"enabled": true,
"analyzer": "standard"
}
},
{
"name": "updated_at",
"type": "long"
}
]
}
}SDK
PutVectorIndexFusion接口所对应的各语言SDK如下:
命令行工具ossutil
PutVectorIndexFusion接口所对应的ossutil命令,请参见put-vector-index-fusion。
错误码
错误码 | HTTP状态码 | 描述 |
VectorIndexParameterInvalid | 400 | 请求中提供的向量索引参数不合法。 |
MalformedJson | 400 | 请求体中的 JSON 格式不符合规范。 |
VectorBucketIndexExceedLimit | 400 | 创建的索引数量已达到上限。单个向量 Bucket 最多允许创建 100 个向量索引。 |
AccessDenied | 403 | 返回该错误的可能原因如下:
|
VectorBucketIndexAlreadyExist | 409 | 指定的索引名称已存在,无法重复创建。 |