AI

Get the Partition Information in Milvus

Milvus is a free and open-source vector database that manages the vectors and metadata, a fundamental feature in machine learning and AI applications.

In Milvus, partitions divide the data into different logical categories. The resulting partitions allow us to segment that stored data effectively, making the data management and searching more efficient.

For example, suppose you have a vector database that stores millions of images. We can partition the images dataset based on the type of images such as landscape, portraits, animals, etc. The partitions allow us to perform the search operations within a specific partition much faster than searching the entire dataset.

In this tutorial, we will learn how to configure a partition and then use the Milvus CLI to gather a detailed information about the resulting partition.

Requirements:

Before proceeding with this tutorial, ensure that the following tools and packages are installed on your system:

  1. Milvus database server, local or remote
  2. Milvus CLI utility

Create a Partition Using Milvus CLI

To create a partition for a given collection using the Milvus CLI utility, we can use the “create partition” command as shown in the following syntax:

create partition -c (text) -p (text) [-d (text)]

The parameters of the previous command are explained as follows:

-c – It denotes the collection name on which you wish to create the partition.

-p – It allows you to specify the name of your target partition.

-d – This is an optional parameter that denotes the description of the target partition.

Let us demonstrate how to create a new Milvus partition using the Milvus CLI.

Start by creating a basic Milvus collection as shown in the following command:

milvus_cli > create collection -c car -f id:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:
color -f brand:INT64:brand id -a -d 'car_collection'

The previous command creates a new collection in Milvus called “car” with four fields: id, vector, color, and brand. The id field is the primary field and partition key.

You can also allow Milvus to configure a default partition when creating a collection using the -p parameter.

However, to manually create a new partition, we can run the command as follows:

milvus_cli > create partition -c car -p new_partition -d sample_partition

The previous command creates a new partition called “new_partition” on the “car” collection with the description of “sample_partition”.

Resulting Output:

+--------------------+---------------+
| Partition Name | new_partition |
+--------------------+---------------+
| Description | |
+--------------------+---------------+
| Is empty | True |
+--------------------+---------------+
| Number of Entities | 0 |
+--------------------+---------------+
Create partition successfully!

Get the Partition Information in Milvus

Once you created the partition, you can gather a detailed information using the “describe partition” command.

The command syntax is as follows:

describe partition -c (text) -p (text)

The -c parameter denotes the collection name, while the -p parameter denotes the target partition name.

For example, to gather an information about the “new_partition” partition that we created in the previous step, we can run the following query:

milvus_cli > describe partition -c car -p new_partition

This command should return the partition information such as the number of entities in the partition, description, empty status, and more.

Conclusion

We learned about the “describe partition” command which allows us to gather an information about an existing Milvus partition. Consider the documentation to discover the command implementation.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list