功能描述
创建命名空间并定义 Schema。未配置
primary_key 时,使用系统 _id 主键,写入时可由服务端自动生成主键值。后续可通过 ModifyNamespace 新增或删除字段。目标命名空间从路径中的
:namespace 推导,向量桶从请求 Host 推导,均不从请求体读取。授权说明
请求
请求示例
POST /_native/<namespace>/_create_namespace HTTP/1.1Host: <bucket>.vectors.<Region>.coslake.comDate: GMT DateContent-Type: application/jsonContent-Length: Content LengthAuthorization: Auth String[Request Body]
说明:
Host:
<bucket>.vectors.<Region>.coslake.com,其中 <Region> 为可用地域。向量桶:向量桶名称采用
<name>-<appid> 格式,例如 examplebucket-1250000000。名称支持小写字母、数字和短横线(-),首尾必须是小写字母或数字,总长度为3 - 63字节,不得包含 ..,末尾必须为数字 APPID。目标向量桶必须为增强型(ENHANCED)。命名空间:由小写字母、数字、短横线(-)和点(.)组成,首尾必须是小写字母或数字,长度为3 - 63字节,不得包含
..。Authorization:Auth String,详情请参见 请求签名 文档。
请求参数
此接口无请求参数。
请求头
请求体
{"schema": {"primary_key": "id","fields": {"id": {"type": "string"},"title": {"type": "text"}}}}
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
schema | 无 | 命名空间 Schema。未配置 primary_key 时使用系统 _id 主键,写入时可自动生成主键值,fields 可省略或为空;配置 primary_key 时须在 fields 中定义对应的 string 字段。字段数量及索引限制以有效配额为准;完整结构请参见 Schema 定义 | object | 是 |
metadata | 无 | 命名空间描述信息,键与值均为字符串 | object | 否 |
响应
响应头
响应体
成功返回 HTTP 200,响应体为空。
错误码
实际案例
案例一:创建带用户主键和向量字段的命名空间
请求
POST /_native/products/_create_namespace HTTP/1.1Host: examplebucket-1250000000.vectors.ap-guangzhou.coslake.comDate: Tue, 08 Sep 2026 10:00:00 GMTContent-Type: application/jsonContent-Length: Content LengthAuthorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=...{"schema": {"primary_key": "id","fields": {"id": {"type": "string"},"title": {"type": "text", "full_text_search": {"enabled": true}},"price": {"type": "float64", "filterable": true},"embedding": {"type": "vector","dimension": 4,"data_type": "float32","distance_metric": "cosine"}}}}
响应
HTTP/1.1 200 OKContent-Length: 0Date: Tue, 08 Sep 2026 10:00:00 GMTx-cos-request-id: Njhk****
案例二:使用系统主键创建命名空间
未配置
primary_key 时,使用系统 _id 主键,写入时可由服务端自动生成主键值。请求
POST /_native/notes/_create_namespace HTTP/1.1Host: examplebucket-1250000000.vectors.ap-guangzhou.coslake.comDate: Tue, 08 Sep 2026 10:00:00 GMTContent-Type: application/jsonContent-Length: Content LengthAuthorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=...{"schema": {"fields": {"title": {"type": "text"},"embedding": {"type": "vector","dimension": 4,"distance_metric": "cosine"}}}}
响应
HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 0Date: Tue, 08 Sep 2026 10:00:00 GMTx-cos-request-id: Njhk****