Create a partition

更新时间:
复制 MD 格式

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:

PlaceholderDescription
<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:

API reference

Method signature

Collection.create_partition(name: str) -> DashVectorResponse

Request parameters

ParameterTypeDefaultDescription
namestr-Name of the partition.
timeoutOptional[int]NoneControls synchronous or asynchronous behavior. See the following table.

Timeout behavior

ValueModeBehavior
NoneSynchronousBlocks until the partition is created, then returns the response.
-1AsynchronousReturns immediately without waiting for the partition to be created.
>= 0Synchronous with deadlineWaits 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:

FieldTypeDescriptionExample
codeintStatus code. 0 indicates success. See Status codes.0
messagestrResult message.success
request_idstrUnique request identifier.19215409-ea66-4db9-8764-26ce2eb5bb99