未验证 提交 76ed2fb4 编写于 作者: Y yukun 提交者: GitHub

The 'num' in return of search is incorrect when use http-api (#3975)

* The 'num' in return of search is incorrect when use http-api
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Add collection name check in GetCollectionInfo
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>
上级 5d9248a1
......@@ -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
......
......@@ -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));
......
......@@ -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<int64_t>();
result_str = result_json.dump();
......
......@@ -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<int64_t>());
ASSERT_EQ(1, result_json["data"]["nq"].get<int64_t>());
}
TEST_F(WebControllerTest, INDEX) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册