Get a collection

Updated at:

Use Client.get() to retrieve an existing collection by name. The returned Collection object is your entry point for document and partition operations, such as inserting documents, running similarity searches, and managing partitions.

Prerequisites

Before you begin, make sure that you have:

Method signature

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

Returns a Collection object on success, or a DashVectorResponse object on failure.

Request parameters

Parameter

Type

Default value

Description

name

str

-

The name of an existing collection.

Example

The following example retrieves a collection named quickstart. Before you run this code, create a collection with that name.

Replace the placeholders with your actual values:

PlaceholderDescription
YOUR_API_KEYYour API key
YOUR_CLUSTER_ENDPOINTYour cluster endpoint
import dashvector

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

# Retrieve the collection
collection = client.get(name='quickstart')

# Verify the call succeeded
assert collection

After the call succeeds, use the collection object to insert documents, run similarity searches, and manage partitions.

Response parameters

On success, Client.get() returns a Collection object that you can use for document and partition operations. On failure, it returns a DashVectorResponse object with the following fields:

Parameter

Type

Description

Example

code

int

Status code. For details, see Status codes.

0

message

str

Result message.

success

request_id

str

Unique request ID.

19215409-ea66-4db9-8764-26ce2eb5bb99