跳到主要内容

插入 Entity

Inserts one or more entities into a collection. You can add a maximum of 100 entities at a time. To insert large volumn of data, you are advised to use the bulk-insert API. For details, refer to Data Import.

POST
/v1/vector/insert
集群 Endpoint

该 API 的 Base URL 格式如下:

https://${CLUSTER_ENDPOINT}

📘说明
export CLUSTER_ENDPOINT=""
参数
Authorizationstringheaderrequired

认证令牌,应为具备适当权限的 API 密钥或用冒号分隔的用户名和密码,如 username:password

示例值:Bearer {{TOKEN}}
请求体application/json
collectionNamestring必填项

Collection 名称。

partitionNamestring

Partition 名称。

dataoneOfrequired

Entity 对象或 Entity 对象数组。注意,Entity 对象的结构应与 Collection Schema 匹配。

A single entity, whose structure should match the schema of the target collection.

export TOKEN="db_admin:xxxxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/insert" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "my_collection",
"data": {
"id": 1,
"vector": [
0.1,
0.2,
0.3,
0.5,
0.6
]
}
}'
export TOKEN="db_admin:xxxxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/insert" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "my_collection",
"data": [
{
"id": 1,
"vector": [
0.1,
0.2,
0.3,
0.5,
0.6
]
},
{
"id": 2,
"vector": [
0.2,
0.3,
0.4,
0.6,
0.7
]
}
]
}'
响应200 - application/json
codeinteger

响应码。

dataobject

响应负载,包含了当前插入操作的统计信息。

insertCountinteger

The number of inserted entities.

insertIdsarray

插入的 Entity ID 数组。

[]insertIdsstring

插入的 Entity ID。

Returns an error message.

codeinteger

响应码。

messagestring

错误描述。

{
"code": 200,
"data": {
"insertCount": 4,
"insertIds": [
"id1",
"id2"
]
}
}