搜索即将作废
本接口在指定 Collection 的向量字段上执行一次相似度搜索。
POST
/v1/vector/search该 API 的 Base URL 格式如下:
https://${CLUSTER_ENDPOINT}
📘说明
- 你需要填入您的 Zilliz Cloud 集群的
${CLUSTER_ENDPOINT}
。 - 您可以使用 查看集群详情来获取集群的 Endpoint.
export CLUSTER_ENDPOINT=""
参数
Authorizationstringheaderrequired
认证令牌。应为具备适当权限的 API 密钥 或用冒号分隔的用户名和密码对,如 username:password
。
示例值:Bearer {{TOKEN}}
请求体application/json
dbNamestring
数据库名称。
collectionNamestring必填项
Collection 名称。
partitionNamesarray
Partition 名称。如果指定该参数,则只在指定 Partition 中进行搜索。如果未指定,则搜索整个 Collection。
[]partitionNamesstring
partitionName
filterstring
搜索时使用的标量过滤条件。
limitinteger
要求返回的最大实体数量。
offset
值与 limit
值的总和不得超过 16,384。
取值范围:≥ 1≤ 16384
offsetinteger
要求在搜索结果中跳过的实体数量。
offset
值与 limit
值的总和不得超过 16,384。
取值范围:0≤ 16384
outputFieldsarray
要求在搜索结果中包含的字段名称列表。
[]outputFieldsstring
随查询结果返回的字段名称。
vectorarrayrequired
以浮点数列表形式表示的查询向量。该查询向量的长度应与 Collection 中向量字段的维度相同。
[]vectornumber<float32>
搜索向量的某个维度的浮点数。
paramsobject
搜索参数列表。
radiusnumber<float64>
与 range_filter
参数一起使用,用于指定查询向量最不相似的向量所在的角度。
range_filternumber<float64>必填项
与 radius
参数一起使用,用于过滤相似度范围内的向量字段值。
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/search" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "quick_setup",
"data": [
[
0.3580376395471989,
-0.6023495712049978,
0.18414012509913835,
-0.26286205330961354,
0.9029438446296592
]
],
"annsField": "vector",
"limit": 3,
"outputFields": [
"color"
]
}'
响应200 - application/json
codeinteger
响应码。
dataarray
响应负载,为搜索结果。
[]dataobject
Search results. By default, each entity object carries the id
and distance
fields. If outputFields
is specified, the entity object also carries the specified fields.
idinteger
Entity ID。
distancenumber<float32>
与查询向量的相似度分数。
Returns an error message.
codeinteger
响应码。
messagestring
错误描述。
{
"code": 200,
"data": [
{
"color": "pink_8682",
"distance": 1,
"id": 0
},
{
"color": "red_7025",
"distance": 0.6290165,
"id": 1
},
{
"color": "red_4794",
"distance": 0.5975797,
"id": 4
}
]
}