put-vector-index

通过put-vector-index命令在向量Bucket中创建向量索引。

注意事项

  • 单个向量 Bucket 中最多创建 100 张向量索引

  • 向量索引 PutVectorIndex 请求每秒最大支持 5 个。

权限说明

阿里云账号默认拥有全部权限。阿里云账号下的RAM用户或RAM角色默认没有任何权限,需要阿里云账号或账号管理员通过RAM PolicyBucket Policy授予操作权限。

API

Action

说明

PutVectorIndex

oss:PutVectorIndex

创建向量索引。

命令格式

ossutil vectors-api put-vector-index --bucket value --index-name value [flags]

参数说明

参数

类型

说明

--bucket

string

向量Bucket名称。

--data-type

string

向量数据类型,当前暂不支持自定义。默认值:float32。

--dimension

int

向量维度,支持1~4096维。默认为512。

--distance-metric

string

距离度量函数。可选值如下:

  • euclidean:欧氏距离(默认值)

  • cosine:余弦距离

--index-name

string

索引名称,用户可自定义,默认为空。

  • 在 Vector Bucket 内全局唯一,长度 1 ~63 字符

  • 只允许字母和数字,首字母必须字母开头

--metadata

string

元数据配置的容器,仅支持填写非过滤元数据。对于非过滤元数据配置,有如下输入限制:

  • 元数据个数为 1~10 个

  • 每个元数据主键名称的长度 1~63 字节

说明

使用示例

  • 为存储桶 examplebucket 创建 index 索引:向量维度 512,数据类型float32,距离度量 euclidean。

    ossutil vectors-api put-vector-index --bucket examplebucket --index-name index --data-type float32 --dimension 512 --distance-metric euclidean
  • 为存储桶 examplebucket 创建 index 索引:向量维度 512,数据类型float32,距离度量 euclidean,并配置非过滤元数据。

    ossutil vectors-api put-vector-index --bucket examplebucket --index-name index --data-type float32 --dimension 512 --distance-metric euclidean --metadata '{"nonFilterableMetadataKeys":["owner","createdBy"]}'