AI

Get Collection Information in Milvus

Milvus is an open-source vector similarity search engine that specializes in handling the vector data where each data point is represented as a vector of numerical values. A collection refers to a data structure and indexing system that is designed to efficiently store and retrieve the high-dimensional data.

A collection is composed of two main components: the data storage and the indexing structure.

A data storage component organizes the vector data for efficient storage and retrieval. In addition, it typically employs various techniques like compression and serialization to optimize the storage requirements.

On the other hand, the indexing structure is responsible for accelerating the similarity search operations. It organizes the vectors to enable the fast search and retrieval based on similarity.

When working with Milvus collections, you will encounter such scenarios where you must gather an information about the collection.

In this tutorial, we will learn how to use the “describe” command in the Milvus CLI to gather a detailed information about a given collection.

Create a Sample Collection in Milvus

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, log in 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

Output:

Connect Milvus successfully.

+---------+---------------------+
| Address | 192.168.100.2:19530 |
| User | |
| Alias | 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'

The previous command should create a new film collection with the defined schema fields and types.

Show the Collection Info in Milvus

To show the collection information using the Milvus CLI, we can use the “describe” command as shown in the following syntax:

describe collection -c (text)

The -c option denotes the target collection name.

For example, to show an information about the film collection, we can run the following command:

milvus_cli > describe collection -c film

This should return the details about the collection as follows:

+---------------+-------------------------------------+
| Name | film |
+---------------+-------------------------------------+
| Description | 'fiml_collection' |
+---------------+-------------------------------------+
| Is Empty | False |
+---------------+-------------------------------------+
| Entities | 8657 |
+---------------+-------------------------------------+
| Primary Field | id |
+---------------+-------------------------------------+
| Schema | Description: 'fiml_collection' |
| | |
| | Auto ID: False |
| | |
| | Fields(* is the primary field): |
| | - *id INT64 primary_field |
| | - film_name VARCHAR |
| | - release_year INT64 release_year |
| | - vector FLOAT_VECTOR dim: 8 |
+---------------+-------------------------------------+
| Partitions | - _default |
+---------------+-------------------------------------+
| Indexes | - vector |
+---------------+-------------------------------------+

The command returns a detailed information about the collection including the available partitions, indexes, number of entries, empty state, and the schema layout.

Conclusion

In this post, you learned how to use the “describe” command in the Milvus CLI to gather the detailed information about a given database collection.

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