All Products
Search
Document Center

DashVector:Obtain a collection

Last Updated:Apr 11, 2024

This topic describes how to obtain an existing collection by using the SDK for Python.

Note

In a collection, you can perform operations on documents and partitions, such as inserting a document, searching for a document, and managing a partition.

Prerequisites

API definition

Client.get(name: str) -> Union[Collection, DashVectorResponse]

Example

Note
  1. You need to replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster in the sample code for the code to run properly.

  2. You need to create a collection named quickstart in advance. For more information, see the "Example" section of the Create a collection topic.

import dashvector

client = dashvector.Client(
    api_key='YOUR_API_KEY',
    endpoint='YOUR_CLUSTER_ENDPOINT'
)

collection = client.get(name='quickstart')

# Check whether the get method is successfully called.
assert collection

Request parameters

Parameter

Type

Default value

Description

name

str

-

The name of the existing collection.

Response parameters

Note
  1. A Collection object is returned if the method is successfully called, which contains the operation result, as described in the following table.

  2. A DashVectorResponse object is returned if the method fails to be called, which contains the operation error information, as described in the following table.

Parameter

Type

Description

Example

code

int

The returned status code. For more information, see Status codes.

0

message

str

The returned message.

success

request_id

str

The unique ID of the request.

19215409-ea66-4db9-8764-26ce2eb5bb99