如何通过HTTP API获取Doc

37 阅读1分钟

本文介绍如何通过HTTP API,根据id列表获取Collection中已存在的Doc。


说明

如果指定id不存在,则该id对应的Doc为空。

前提条件

Method与URL

HTTP

GET https://{Endpoint}/v1/collections/{CollectionName}/docs?ids={IDs}&partition={PartitionName}

使用示例

说明

  1. 需要使用您的api-key替换示例中的YOUR_API_KEY、您的Cluster Endpoint替换示例中的YOUR_CLUSTER_ENDPOINT,代码才能正常运行。
  2. 本示例需要参考新建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
#     }
#   }
# }