A partition is a logical subset of a collection that groups related vectors together.
Quick start
The following example creates a partition named shoes in the quickstart collection and verifies the result.
import dashvector
client = dashvector.Client(
api_key='<your-api-key>',
endpoint='<your-cluster-endpoint>'
)
collection = client.get(name='quickstart')
# Create a partition
ret = collection.create_partition('shoes')
# Verify the result
if ret:
print('create_partition success')Replace the placeholders with your actual values:
| Placeholder | Description |
|---|---|
<your-api-key> | API key for your DashVector cluster |
<your-cluster-endpoint> | Endpoint of your DashVector cluster |
For more details on the request and response parameters, see API reference.
Prerequisites
Before you begin, make sure you have:
A DashVector cluster. See Create a cluster
An API key. See Get an API key
The latest DashVector SDK. See Install the DashVector SDK
A collection named
quickstart. See the example in Create a collection
API reference
Method signature
Collection.create_partition(name: str) -> DashVectorResponseRequest parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| name | str | - | Name of the partition. |
| timeout | Optional[int] | None | Controls synchronous or asynchronous behavior. See the following table. |
Timeout behavior
| Value | Mode | Behavior |
|---|---|---|
None | Synchronous | Blocks until the partition is created, then returns the response. |
-1 | Asynchronous | Returns immediately without waiting for the partition to be created. |
>= 0 | Synchronous with deadline | Waits up to the specified time period. Returns a timeout error if creation does not complete in time. |
Response parameters
create_partition returns a DashVectorResponse object with the following fields:
| Field | Type | Description | Example |
|---|---|---|---|
| code | int | Status code. 0 indicates success. See Status codes. | 0 |
| message | str | Result message. | success |
| request_id | str | Unique request identifier. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
该文章对您有帮助吗?