本文介紹如何通過HTTP API,根據id列表獲取Collection中已存在的Doc。
説明
如果指定id不存在,則該id對應的Doc為空。
前提條件
- 已創建Cluster:創建Cluster。
- 已獲得API-KEY:API-KEY管理。
Method與URL
HTTP
GET https://{Endpoint}/v1/collections/{CollectionName}/docs?ids={IDs}&partition={PartitionName}
使用示例
説明
- 需要使用您的api-key替換示例中的YOUR_API_KEY、您的Cluster Endpoint替換示例中的YOUR_CLUSTER_ENDPOINT,代碼才能正常運行。
- 本示例需要參考新建Collection-使用示例提前創建好名稱為
quickstart的Collection
Shell
curl -H 'dashvector-auth-token: YOUR_API_KEY' \
'https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs?ids=1,2'
# example output:
# {
# "code": 0,
# "request_id": "b6e03358-d396-445d-88a5-d5e9bb1edead",
# "message": "Success",
# "output": {
# "1": {
# "id": "1",
# "vector": [
# 0.1,
# 0.2,
# 0.3,
# 0.4
# ],
# "fields": {
# "name": null,
# "weight": null,
# "age": null
# },
# "score": 0.0
# },
# "2": {
# "id": "2",
# "vector": [
# 0.2,
# 0.3,
# 0.4,
# 0.5
# ],
# "fields": {
# "name": "zhangsan",
# "weight": null,
# "age": 20
# },
# "score": 0.0
# }
# }
# }
入參描述
|
參數 |
Location |
類型 |
必填 |
説明 |
|
{Endpoint} |
path |
str |
是 |
Cluster的Endpoint,可在控制枱Cluster詳情中查看 |
|
{CollectionName} |
path |
str |
是 |
Collection名稱 |
|
dashvector-auth-token |
header |
str |
是 |
api-key |
|
{IDs} |
query param |
str |
是 |
待獲取的Doc |
|
{PartitionName} |
query param |
str |
否 |
Partition名稱 |
出參描述
|
字段 |
類型 |
描述 |
示例 |
|
code |
int |
返回值,參考返回狀態碼説明 |
0 |
|
message |
str |
返回消息 |
success |
|
request_id |
str |
請求唯一id |
19215409-ea66-4db9-8764-26ce2eb5bb99 |
|
output |
object |
key為Doc id、value為對應Doc的Dict |
|
|
usage |
map |
對Serverless實例(按量付費)集合的Doc獲取請求,成功後返回實際消耗的讀請求單元數 |
|