Retrieve one or more documents from a DashVector collection by their IDs. Each returned document includes its vector, fields, and score.
If a specified ID does not exist, the corresponding output is empty.
Prerequisites
Before you begin, make sure that you have:
A DashVector cluster. For more information, see Create a cluster
An API key. For more information, see Manage API keys
The latest version of the DashVector SDK. For more information, see Install DashVector SDK
Request syntax
GET https://{Endpoint}/v1/collections/{CollectionName}/docs?ids={IDs}&partition={PartitionName}Request parameters
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
{Endpoint} | Path | String | Yes | The cluster endpoint. Find this on the cluster details page in the console. |
{CollectionName} | Path | String | Yes | The name of the collection to query. |
dashvector-auth-token | Header | String | Yes | The API key for authentication. |
{IDs} | Query | String | Yes | A comma-separated list of document IDs to retrieve. |
{PartitionName} | Query | String | No | The name of the partition to query. |
Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
code | Integer | The status code. 0 indicates success. For more information, see Status codes. | 0 |
message | String | A human-readable status message. | Success |
request_id | String | A unique identifier for the request, useful for troubleshooting. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
output | Object | A 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. | |
Example
This example fetches documents with IDs 1 and 2 from a collection named quickstart.
Replace the following placeholders with your actual values:
| Placeholder | Replace with | How to get the value |
|---|---|---|
YOUR_API_KEY | Your API key | See Manage API keys |
YOUR_CLUSTER_ENDPOINT | Your cluster endpoint | See Cluster details in the console |
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.