跳到主要内容

添加 Collection Struct 字段 (V2)

This operation adds a StructArray field to an existing collection.

POST/v2/vectordb/collections/struct_fields/add
连接端点

该 API 的 Base URL 格式如下:

https://${CLUSTER_ENDPOINT}

📘说明
  • 你需要填入您的 Zilliz Cloud 集群的 ${CLUSTER_ENDPOINT}
  • 您可以使用 查看集群详情 V2 来获取集群的 Endpoint.
shell
export CLUSTER_ENDPOINT=""
参数
Authorizationstringheader必填项

认证令牌,应为具备适当权限的 API 密钥或用冒号分隔的用户名和密码,如 username:password。如果您使用的是项目端点,则仅具备足够权限的有效 API 密钥适用。

示例值:Bearer {{TOKEN}}
请求体
dbNamestring

Database 名称。若未指定,则使用默认 Database。

collectionNamestring必填项

目标 Collection 的名称。

schemaobject必填项

StructArray 字段 Schema。

fieldNamestring必填项

StructArray 字段的名称。

descriptionstring

StructArray 字段的描述。

dataTypestring必填项

StructArray 数据类型。可设为 ArrayOfStruct,或设为 Array 并将 elementDataType 设为 Struct。

elementDataTypestring

当 dataType 为 Array 时,元素数据类型须设为 Struct。

fieldsarray必填项

StructArray 字段中的标量或向量子字段。

[]fieldsobject必填项

Struct Array 中的子字段定义。dataType 表示 Struct 字段的标量或向量类型。

fieldNamestring必填项

子字段名称。

dataTypestring必填项

Struct 字段的标量或向量类型。

elementTypeParamsobject

元素类型参数,例如 VarChar 的 max_length 或向量类型的 dim。

typeParamsobject

StructArray 字段的附加参数。

max_capacityinteger

每条 Entity 中允许包含的 Struct 元素数量上限。

取值范围:≥ 1≤ 4096
nullableboolean

StructArray 字段是否允许为 null。

bash
export TOKEN="db_admin:xxxxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/struct_fields/add" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Request-Timeout: 5" \
--header "Content-Type: application/json" \
-d '{
"dbName": "default",
"collectionName": "documents",
"schema": {
"fieldName": "chunks",
"dataType": "ArrayOfStruct",
"fields": [
{
"fieldName": "text",
"dataType": "Array",
"elementDataType": "VarChar",
"elementTypeParams": {
"max_length": 1024
}
}
],
"typeParams": {
"max_capacity": 100
}
}
}'
响应

返回空对象。

codeinteger

响应码。

dataobject

返回错误消息。

codeinteger

响应码。

messagestring

错误描述。

Ctrl I