AI

Drop a Collection in Milvus

In Milvus, a collection refers to the primary storage structure for the data that is stored in the Milvus database. It is similar to a table in relational databases.

This tutorial teaches us how to use the Milvus CLI to drop an existing collection from the database.

Requirements:

To follow along with this tutorial, you are required with the following:

  1. Installed Milvus on your machine. You can use the Docker, a standalone install, or a remote instance.
  2. Installed Milvus CLI on your machine
  3. Attu Manager

Creating a Milvus Collection

Before learning how to drop an existing Milvus collection, let us start by setting up a sample Milvus collection for demonstration purposes.

Start by opening the Milvus CLI with the following command:

$ milvus_cli

Next, login to your Milvus instance with the following command:

milvus_cli > connect -h <host> -p <port> -a <alias>

For example, the following command logs into a locally hosted Milvus instance on the default port and alias.

milvus_cli > connect -h 127.0.0.1 -p 19530 -a default

Once logged in, we can create a sample Milvus collection as shown in the following command:

milvus_cli > create collection -c film -f id:INT64:primary_field -f film_name:VARCHAR:100 -f release_year:INT64:release_year -f vector:FLOAT_VECTOR:8 -p id -d 'fiml_collection'

We call the “create collection” command to create a new collection in Milvus.

Next, we use the -c parameter to specify the collection’s name. In this case, the collection name is “film.”

The -f parameter allows us to specify the fields of the collection and their corresponding types within the collection. In this collection, the fields are defined as follows:

id:INT64:primary_field – This specifies the field named “id” of type INT64, and it is marked as the primary field. The primary field is used to uniquely identify the records in the collection.

film_name VARCHAR:100 – This specifies the field named “film_name” of type VARCHAR with a maximum length of 100 characters.

release_year:INT64:release_year – This specifies the field named “release_year” of type INT64.

vector:FLOAT_VECTOR:8 – This specifies the field named “vector” as a vector field of type FLOAT_VECTOR with a dimension of 8.

The -p id parameter allows us to specify the primary key for the collection. In this case, we specify the primary key as the “id” field.

Finally, we use the -d parameter to specify the description for the collection.

Delete a Collection in Milvus

If you no longer need a collection, you can remove it using the “delete collection” command as shown in the following syntax:

delete collection -c (collection_name) [-t (timeout)]

For example, to remove the film collection, run the following command:

milvus_cli > delete collection -c film

This should prompt you whether you wish to remove the collection. Press “Y” to accept.

Drop a Collection in Milvus Using Attu

You can also use the Attu manager to drop an existing collection. Launch the Attu manager and connect to your target server.

Once connected, navigate to the collections pane and locate the collection that you wish to delete. Select the target collection and choose the bin icon.

This will prompt you to confirm whether you wish to delete the collection.

Conclusion

This comprehensive tutorial taught us how to create and delete an existing Milvus collection from the server using the Milvus CLI and the Attu Manager.

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