HasCollection()
This operation checks whether the specified collection exists.
Status HasCollection(const HasCollectionRequest& request, HasCollectionResponse& response)
Request Syntax
auto request = HasCollectionRequest()
.WithDatabaseName(db_name)
.WithCollectionName(collection_name);
REQUEST METHODS:
WithDatabaseName(const std::string& db_name)Sets the name of the target database. The default database applies if it is empty.
WithCollectionName(const std::string& collection_name)Sets the name of the target collection.
RETURNS:
Status with HasCollectionResponse
Check status.IsOk() to confirm success.
EXCEPTIONS:
StatusCode
Check
status.Code()andstatus.Message()for error details.
Example
#include "milvus/MilvusClientV2.h"
auto client = milvus::MilvusClientV2::Create();
milvus::ConnectParam connect_param{"http://localhost:19530", "root:Milvus"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
milvus::HasCollectionResponse response;
status = client->HasCollection(
milvus::HasCollectionRequest()
.WithCollectionName("my_collection"),
response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
std::cout << "Collection exists: " << response.HasCollection() << std::endl;