milvus-logo
Star
0
Forks
0
快速开始

Check Collection Information

Milvus Docs 需要你的帮助

本文档暂时没有中文版本,欢迎你成为社区贡献者,协助中文技术文档的翻译。
你可以通过页面右边的 编辑 按钮直接贡献你的翻译。更多详情,参考 贡献指南。如需帮助,你可以 提交 GitHub Issue

This topic describes how to check the information of the collection in Milvus.

Check if a collection exists

Verify if a collection exists in Milvus.

from pymilvus import utility
utility.has_collection("book")
await milvusClient.collectionManager.hasCollection({
  collection_name: "book",
});
hasColl, err := milvusClient.HasCollection(
    context.Background(), // ctx
    collectionName,       // CollectionName
)
if err != nil {
    log.Fatal("failed to check whether collection exists:", err.Error())
}
log.Println(hasColl)
R<Boolean> respHasCollection = milvusClient.hasCollection(
        HasCollectionParam.newBuilder()
                .withCollectionName("book")
                .build());
if (respHasCollection.getData() == Boolean.TRUE) {
    System.out.println("Collection exists.");
}
describe collection -c book
Parameter Description
collection_name Name of the collection to check.
Parameter Description
collection_name Name of the collection to check.
Parameter Description
ctx Context to control API invocation process.
CollectionName Name of the collection to check.
Parameter Description
CollectionName Name of the collection to check.
Option Description
-c Name of the collection to check.

Check collection details

Check the details of a collection.

from pymilvus import Collection
collection = Collection("book")  # Get an existing collection.

collection.schema                # Return the schema.CollectionSchema of the collection.
collection.description           # Return the description of the collection.
collection.name                  # Return the name of the collection.
collection.is_empty              # Return the boolean value that indicates if the collection is empty.
collection.num_entities          # Return the number of entities in the collection.
collection.primary_field         # Return the schema.FieldSchema of the primary key field.
collection.partitions            # Return the list[Partition] object.
collection.indexes               # Return the list[Index] object.
await milvusClient.collectionManager.describeCollection({          // Return the name and schema of the collection.
  collection_name: "book",
});

await milvusClient.collectionManager.getCollectionStatistics({     // Return the statistics information of the collection.
  collection_name: "book",
});
collDesc, err := milvusClient.DescribeCollection(               // Return the name and schema of the collection.
    context.Background(),   // ctx
    "book",                 // CollectionName
)
if err != nil {
    log.Fatal("failed to check collection schema:", err.Error())
}
log.Printf("%v\n", collDesc)

collStat, err := milvusClient.GetCollectionStatistics(          // Return the statistics information of the collection.
    context.Background(),   // ctx
    "book",                 // CollectionName
)
if err != nil {
log.Fatal("failed to check collection statistics:", err.Error())
}
R<DescribeCollectionResponse> respDescribeCollection = milvusClient.describeCollection(          // Return the name and schema of the collection.
        DescribeCollectionParam.newBuilder()
                .withCollectionName("book")
                .build());
DescCollResponseWrapper wrapperDescribeCollection = new DescCollResponseWrapper(respDescribeCollection.getData());
System.out.println(wrapperDescribeCollection);

R<GetCollectionStatisticsResponse> respCollectionStatistics = milvusClient.getCollectionStatistics(   // Return the statistics information of the collection.
        GetCollectionStatisticsParam.newBuilder()
                .withCollectionName("book")
                .build());
GetCollStatResponseWrapper wrapperCollectionStatistics = new GetCollStatResponseWrapper(respCollectionStatistics.getData());
System.out.println("Collection row count: " + wrapperCollectionStatistics.getRowCount());
describe collection -c book
Property Return Exception
schema The schema of the collection.
description The description of the collection.
name The name of the collection.
is_empty A boolean value that indicates whether the collection is empty.
num_entities The number of entities in the collection. CollectionNotExistException is raised if the collection does not exist.
primary_field The primary field of the collection.
partitions A list of all partitions. CollectionNotExistException is raised if the collection does not exist.
indexes A list of all indexes. CollectionNotExistException is raised if the collection does not exist.
Parameter Description
collection_name Name of the collection to check.
        <th>Description</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td><code>status</code></td>
        <td>{ error_code: number, reason: string }</td>
    </tr>
    <tr>
        <td><code>schema</code></td>
        <td>Information of all fields in this collection</td>
    <tr>
        <td><code>collectionID</code></td>
        <td> collectionID</td>
    </tr>
</tbody>
Property
Parameter ctx Context to control API invocation process.
CollectionName Name of the collection to check.
Parameter Description
CollectionName Name of the collection to check.
Option Description
-c Name of the collection to check.

List all collections

List all collections in this Milvus Instance.

from pymilvus import utility
utility.list_collections()
await milvusClient.collectionManager.showCollections();
listColl, err := milvusClient.ListCollection(
    context.Background(),   // ctx
    )
if err != nil {
		log.Fatal("failed to list all collections:", err.Error())
    }
log.Println(listColl)
R<ShowCollectionsResponse> respShowCollections = milvusClient.showCollections(
        ShowCollectionsParam.newBuilder()
                .build());
System.out.println(respShowCollections);
list collections
Parameter Description
ctx Context to control API invocation process.

What's next

    该页面是否对你有帮助?
    本页目录