HasCollectionAsync()
Checks whether a collection exists.
public async Task<HasCollectionResp> HasCollectionAsync(HasCollectionReq request, CancellationToken cancellationToken = default)
Request Syntax
var request = new HasCollectionReq
{
CollectionName = "my_collection"
};
HasCollectionResp result = await client.HasCollectionAsync(request);
REQUEST PARAMETERS:
DatabaseName(string?) -An optional database name to operate on. When empty, the client’s currently selected database is used.
CollectionName(string) -The name of the collection to check.
RETURN TYPE:
Task
RETURNS:
A HasCollectionResp object that indicates whether the collection exists.
HasCollectionResp
Has // -> bool
PARAMETERS:
Has (bool) -
Whether the collection exists.
EXCEPTIONS:
-
Thrown when the RPC fails or the server returns an error. Inspect the exception message for details.
Example
using Milvus.Client.V2;
using Milvus.Client.V2.Requests.Collection;
using Milvus.Client.V2.Responses.Collection;
using Milvus.Client.V2.Types;
using var client = new MilvusClientV2(new ConnectConfig
{
Uri = "localhost:19530",
Username = "root",
Password = "Milvus"
});
await client.ConnectAsync();
HasCollectionResp result = await client.HasCollectionAsync(new HasCollectionReq
{
CollectionName = "my_collection"
});