Milvus is an open-source vector database for large-scale machine learning and data analytics workloads. It provides an efficient storage and retrieval of high-dimensional vectors that represent the complex data such as images, text, and audio.
Milvus utilizes a data structure called the vector index which organizes and indexes the vectors to enable a fast similarity search. The index employs the advanced algorithms, such as approximate nearest neighbor (ANN) search techniques, to quickly find the vectors that are similar or close in the distance to a given query vector.
In this tutorial, we will learn how to create and drop a collection index in the Milvus database using the Milvus CLI.
Prerequisites:
- Access to a Milvus server
- Installed Milvus CLI on your local machine
With the given requirements met, we can proceed to the next steps.
Create a Collection in Milvus CLI
The first step is to create a collection for demonstration purposes. Start by logging to the Milvus CLI and run the following command:
This should create a simple “car” collection.
Create an Index in Milvus
Once you configure the collection, run the “create index” command to configure a new index. Ensure to follow the provided prompts.
Collection name (car, car2): car
The name of the field to create an index for (vector): vector
Index name: vectorIndex
Index type (FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, RNSG, HNSW, ANNOY): IVF_FLAT
Index metric type (L2, IP, HAMMING, TANIMOTO): L2
Index params nlist: 2
Timeout []:
Milvus CLI Drop Index
Once you finish the index, you can remove it from the server using the “delete index” command. You can use the command syntax as shown in the following:
The -c parameter denotes the collection name, and the -in parameter denotes the index name that you wish to remove.
For example, you can use the following command:
The previous command removes the “vectorIndex” index from the specified collection.
Conclusion
This tutorial explored the basics of working with a given collection using the Milvus CLI commands.