Skip to content

Commit 28b9ca9

Browse files
authored
Fix a bug of DropIndex (#458)
Signed-off-by: yhmo <yihua.mo@zilliz.com>
1 parent 1476a7a commit 28b9ca9

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/impl/MilvusClientV2Impl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,11 +1039,13 @@ MilvusClientV2Impl::DropIndex(const DropIndexRequest& request) {
10391039
auto pre = [&request](proto::milvus::DropIndexRequest& rpc_request) {
10401040
rpc_request.set_db_name(request.DatabaseName());
10411041
rpc_request.set_collection_name(request.CollectionName());
1042+
// the proto uses set_index_name to pass index name or field name
10421043
if (!request.IndexName().empty()) {
10431044
rpc_request.set_index_name(request.IndexName());
1044-
} else {
1045-
rpc_request.set_field_name(request.FieldName());
1045+
} else if (!request.FieldName().empty()) {
1046+
rpc_request.set_index_name(request.FieldName());
10461047
}
1048+
10471049
return Status::OK();
10481050
};
10491051
return connection_.Invoke<proto::milvus::DropIndexRequest, proto::common::Status>(pre,

test/st/cases/TestIndex.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ TEST_F(MilvusServerTestIndex, CreateDescribeListDrop) {
8787
status =
8888
client_->DropIndex(milvus::DropIndexRequest().WithCollectionName(collection_name).WithIndexName("my_index"));
8989
milvus::test::ExpectStatusOK(status);
90-
std::cout << "index dropped" << std::endl;
9190

9291
// verify dropped
9392
milvus::ListIndexesResponse list_resp2;
@@ -97,17 +96,31 @@ TEST_F(MilvusServerTestIndex, CreateDescribeListDrop) {
9796
}
9897

9998
TEST_F(MilvusServerTestIndex, CreateHNSWIndex) {
100-
milvus::IndexDesc index_desc("vec", "hnsw_index", milvus::IndexType::HNSW, milvus::MetricType::L2);
99+
milvus::IndexDesc index_desc("vec", "", milvus::IndexType::HNSW, milvus::MetricType::L2);
101100
index_desc.AddExtraParam("M", "16");
102101
index_desc.AddExtraParam("efConstruction", "200");
103102
auto status = client_->CreateIndex(
104103
milvus::CreateIndexRequest().WithCollectionName(collection_name).AddIndex(std::move(index_desc)));
105104
milvus::test::ExpectStatusOK(status);
106105

106+
status =
107+
client_->LoadCollection(milvus::LoadCollectionRequest().WithCollectionName(collection_name).WithReplicaNum(1));
108+
milvus::test::ExpectStatusOK(status);
109+
107110
milvus::DescribeIndexResponse desc_resp;
108111
status = client_->DescribeIndex(
109112
milvus::DescribeIndexRequest().WithCollectionName(collection_name).WithFieldName("vec"), desc_resp);
110113
milvus::test::ExpectStatusOK(status);
114+
EXPECT_EQ(desc_resp.Descs().size(), 1);
115+
EXPECT_EQ(desc_resp.Descs()[0].FieldName(), "vec");
116+
EXPECT_EQ(desc_resp.Descs()[0].IndexName(), "vec");
117+
118+
status = client_->ReleaseCollection(milvus::ReleaseCollectionRequest().WithCollectionName(collection_name));
119+
milvus::test::ExpectStatusOK(status);
120+
121+
// drop index
122+
status = client_->DropIndex(milvus::DropIndexRequest().WithCollectionName(collection_name).WithFieldName("vec"));
123+
milvus::test::ExpectStatusOK(status);
111124
}
112125

113126
TEST_F(MilvusServerTestIndex, AlterAndDropIndexProperties) {
@@ -155,4 +168,8 @@ TEST_F(MilvusServerTestIndex, AlterAndDropIndexProperties) {
155168
params = desc_resp.Descs()[0].ExtraParams();
156169
EXPECT_EQ(params.size(), 2); // M, efConstruction
157170
EXPECT_TRUE(params.find("mmap.enabled") == params.end());
171+
172+
// drop index
173+
status = client_->DropIndex(milvus::DropIndexRequest().WithCollectionName(collection_name).WithFieldName("vec"));
174+
milvus::test::ExpectStatusOK(status);
158175
}

0 commit comments

Comments
 (0)