Partition Operations
Partition APIs manage collection partitions. Use partitions to organize data within a collection and optionally load or release only selected partitions.
createPartition
Section titled “createPartition”Create a partition in a collection.
createPartition(data: CreatePartitionReq): Promise<ResStatus>Parameters:
collection_name: Collection name.partition_name: Partition name.db_name?: Database name.timeout?: Request timeout in milliseconds.
Example:
await client.createPartition({ collection_name: 'books', partition_name: 'tenant_a',});hasPartition
Section titled “hasPartition”Check whether a partition exists.
hasPartition(data: HasPartitionReq): Promise<BoolResponse>Parameters:
collection_name: Collection name.partition_name: Partition name.db_name?: Database name.timeout?: Request timeout in milliseconds.
Response:
status: Response status.value:truewhen the partition exists.
Example:
const exists = await client.hasPartition({ collection_name: 'books', partition_name: 'tenant_a',});listPartitions
Section titled “listPartitions”List partitions in a collection.
listPartitions(data: ShowPartitionsReq): Promise<ShowPartitionsResponse>showPartitions(data: ShowPartitionsReq): Promise<ShowPartitionsResponse> // aliasParameters:
collection_name: Collection name.type?:ShowPartitionsType.AllorShowPartitionsType.Loaded.db_name?: Database name.timeout?: Request timeout in milliseconds.
Response:
partition_names: Partition names.partitionIDs: Partition IDs.data[]: Formatted partition info withname,id,timestamp, andloadedPercentage.
Example:
const partitions = await client.listPartitions({ collection_name: 'books' });console.log(partitions.partition_names);getPartitionStatistics
Section titled “getPartitionStatistics”Get partition statistics.
getPartitionStatistics(data: GetPartitionStatisticsReq): Promise<StatisticsResponse>getPartitionStats(data: GetPartitionStatisticsReq): Promise<StatisticsResponse> // aliasParameters:
collection_name: Collection name.partition_name: Partition name.db_name?: Database name.timeout?: Request timeout in milliseconds.
Response:
stats: Raw key-value statistics.data.row_count: Parsed row count.
Example:
const stats = await client.getPartitionStatistics({ collection_name: 'books', partition_name: 'tenant_a',});loadPartitions
Section titled “loadPartitions”Load one or more partitions into query nodes.
loadPartitions(data: LoadPartitionsReq): Promise<ResStatus>Parameters:
collection_name: Collection name.partition_names: Partition names to load.replica_number?: Number of replicas.resource_groups?: Resource groups to load into.db_name?: Database name.timeout?: Request timeout in milliseconds.
Example:
await client.loadPartitions({ collection_name: 'books', partition_names: ['tenant_a'], replica_number: 1,});loadPartitionsSync
Section titled “loadPartitionsSync”Load partitions and wait until loading progress reaches 100%.
loadPartitionsSync(data: LoadPartitionsReq): Promise<ResStatus>Throws if loading fails.
releasePartitions
Section titled “releasePartitions”Release partitions from query nodes.
releasePartitions(data: ReleasePartitionsReq): Promise<ResStatus>Parameters:
collection_name: Collection name.partition_names: Partition names to release.db_name?: Database name.timeout?: Request timeout in milliseconds.
Example:
await client.releasePartitions({ collection_name: 'books', partition_names: ['tenant_a'],});dropPartition
Section titled “dropPartition”Drop a partition and all data in it. The default partition cannot be dropped.
dropPartition(data: DropPartitionReq): Promise<ResStatus>Parameters:
collection_name: Collection name.partition_name: Partition name.db_name?: Database name.timeout?: Request timeout in milliseconds.
Example:
await client.dropPartition({ collection_name: 'books', partition_name: 'tenant_a',});