Get docs

更新时间:
复制 MD 格式

Retrieve one or more documents from a DashVector collection by their IDs. Each returned document includes its vector, fields, and score.

Note

If a specified ID does not exist, the corresponding output is empty.

Prerequisites

Before you begin, make sure that you have:

Request syntax

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

Request parameters

ParameterLocationTypeRequiredDescription
{Endpoint}PathStringYesThe cluster endpoint. Find this on the cluster details page in the console.
{CollectionName}PathStringYesThe name of the collection to query.
dashvector-auth-tokenHeaderStringYesThe API key for authentication.
{IDs}QueryStringYesA comma-separated list of document IDs to retrieve.
{PartitionName}QueryStringNoThe name of the partition to query.

Response parameters

ParameterTypeDescriptionExample
codeIntegerThe status code. 0 indicates success. For more information, see Status codes.0
messageStringA human-readable status message.Success
request_idStringA unique identifier for the request, useful for troubleshooting.19215409-ea66-4db9-8764-26ce2eb5bb99
outputObjectA map of document IDs to Doc objects. Each Doc contains id, vector, fields, and score.See the example response.

usage

map

For successful doc retrieval requests on a serverless (pay-as-you-go) collection, this parameter returns the number of consumed read request units.

{
    Usage: {
        read_units: 1
    }
}

Example

This example fetches documents with IDs 1 and 2 from a collection named quickstart.

Replace the following placeholders with your actual values:

PlaceholderReplace withHow to get the value
YOUR_API_KEYYour API keySee Manage API keys
YOUR_CLUSTER_ENDPOINTYour cluster endpointSee Cluster details in the console
Note

Create a collection named quickstart before running this example. For instructions, see the "Example" section of Create a collection.

Request

curl -H 'dashvector-auth-token: YOUR_API_KEY' \
  'https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs?ids=1,2'

Response

{
  "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
    }
  }
}

The response contains two documents. Document 1 has no populated fields, while document 2 includes a name and age value. Both documents return their full vector data and a score of 0.0.