All Products
Search
Document Center

DashVector:Create a partition

Last Updated:Apr 11, 2024

This topic describes how to create a partition in a collection by using the SDK for Python.

Prerequisites

API definition

Collection.create_partition(name: str) -> 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')

# Create a partition named shoes.
ret = collection.create_partition('shoes')

# Check whether the create_partition method is successfully called.
if ret:
    print('create_partition success')

Request parameters

Parameter

Type

Default value

Description

name

str

-

The name of the partition to be created.

timeout

Optional[int]

None

  • The timeout period. If you set timeout to None, the method works in synchronous mode and returns a response when the partition is successfully created.

  • If you set timeout to -1, the method works in asynchronous mode.

  • If you set timeout to a value greater than or equal to 0, the method works in synchronous mode and waits for the operation result within the specified time period. The method returns a timeout error if the partition fails to be created within the specified timeout period.

Response parameters

Note

A DashVectorResponse object is returned, which contains the operation result, 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