diff --git a/CHANGELOG.md b/CHANGELOG.md index a3b413e80d..16dd4b2dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Please mark all changes in change log and use the issue from GitHub - \#3741 Inconsistent parameter names - \#3811 c++ sdk segmentation fault - \#3946 The result format is wrong returned by 'get collections' +- \#3962 The 'num' in return of search is incorrect when use http-api ## Feature - \#2319 Redo metadata to support MVCC diff --git a/core/src/server/delivery/request/GetCollectionInfoReq.cpp b/core/src/server/delivery/request/GetCollectionInfoReq.cpp index 70f08eae31..844b16a4c5 100644 --- a/core/src/server/delivery/request/GetCollectionInfoReq.cpp +++ b/core/src/server/delivery/request/GetCollectionInfoReq.cpp @@ -43,6 +43,12 @@ GetCollectionInfoReq::OnExecute() { STATUS_CHECK(ValidateCollectionName(collection_name_)); + bool exist = false; + STATUS_CHECK(DBWrapper::DB()->HasCollection(collection_name_, exist)); + if (!exist) { + return Status(SERVER_COLLECTION_NOT_EXIST, "Collection not exist: " + collection_name_); + } + engine::snapshot::CollectionPtr collection; engine::snapshot::FieldElementMappings field_mappings; STATUS_CHECK(DBWrapper::DB()->GetCollectionInfo(collection_name_, collection, field_mappings)); diff --git a/core/src/server/web_impl/handler/WebRequestHandler.cpp b/core/src/server/web_impl/handler/WebRequestHandler.cpp index 10d5303c6b..987b3bf85f 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.cpp +++ b/core/src/server/web_impl/handler/WebRequestHandler.cpp @@ -826,7 +826,7 @@ WebRequestHandler::Search(const std::string& collection_name, const nlohmann::js } nlohmann::json result_json; - result_json["num"] = result->row_num_; + result_json["nq"] = result->row_num_; if (result->row_num_ == 0) { result_json["result"] = std::vector(); result_str = result_json.dump(); diff --git a/core/unittest/server/test_web.cpp b/core/unittest/server/test_web.cpp index c8f2779aa1..b759d1b89d 100644 --- a/core/unittest/server/test_web.cpp +++ b/core/unittest/server/test_web.cpp @@ -825,7 +825,7 @@ TEST_F(WebControllerTest, SEARCH) { // ASSERT_EQ(milvus::server::web::StatusCode::SUCCESS, error_dto->code); auto result_json = nlohmann::json::parse(response->readBodyToString()->std_str()); ASSERT_TRUE(result_json.contains("data")); - ASSERT_EQ(1, result_json["data"]["num"].get()); + ASSERT_EQ(1, result_json["data"]["nq"].get()); } TEST_F(WebControllerTest, INDEX) {