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

The result format is wrong returned by get collections (#3948)

* The result format is wrong returned by get collections
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Add data in the result of search
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>
上级 7f396a63
......@@ -51,6 +51,7 @@ Please mark all changes in change log and use the issue from GitHub
- \#3734 GET_PAGE_ENTITY sometimes failed in test_web
- \#3741 Inconsistent parameter names
- \#3811 c++ sdk segmentation fault
- \#3946 The result format is wrong returned by 'get collections'
## Feature
- \#2319 Redo metadata to support MVCC
......
......@@ -290,8 +290,7 @@ WebRequestHandler::GetCollectionMetaInfo(const std::string& collection_name, nlo
int64_t count;
STATUS_CHECK(req_handler_.CountEntities(context_ptr_, collection_name, count));
nlohmann::json result_json;
result_json["collection_name"] = schema.collection_name_;
json_out["collection_name"] = schema.collection_name_;
for (const auto& field : schema.fields_) {
if (field.first == engine::FIELD_UID) {
continue;
......@@ -301,16 +300,15 @@ WebRequestHandler::GetCollectionMetaInfo(const std::string& collection_name, nlo
field_json["type"] = type2str.at(field.second.field_type_);
field_json["index_params"] = field.second.index_params_;
field_json["params"] = field.second.field_params_;
result_json["fields"].push_back(field_json);
json_out["fields"].push_back(field_json);
}
if (schema.extra_params_.contains(engine::PARAM_SEGMENT_ROW_COUNT)) {
result_json[engine::PARAM_SEGMENT_ROW_COUNT] = schema.extra_params_[engine::PARAM_SEGMENT_ROW_COUNT];
json_out[engine::PARAM_SEGMENT_ROW_COUNT] = schema.extra_params_[engine::PARAM_SEGMENT_ROW_COUNT];
}
if (schema.extra_params_.contains(engine::PARAM_UID_AUTOGEN)) {
result_json[engine::PARAM_UID_AUTOGEN] = schema.extra_params_[engine::PARAM_UID_AUTOGEN];
json_out[engine::PARAM_UID_AUTOGEN] = schema.extra_params_[engine::PARAM_UID_AUTOGEN];
}
result_json["count"] = count;
json_out["data"] = result_json;
json_out["count"] = count;
return Status::OK();
}
......@@ -906,7 +904,9 @@ WebRequestHandler::Search(const std::string& collection_name, const nlohmann::js
}
result_json["result"].push_back(raw_result_json);
}
result_str = result_json.dump();
nlohmann::json data_json;
data_json["data"] = result_json;
result_str = data_json.dump();
}
return Status::OK();
......@@ -1370,7 +1370,9 @@ WebRequestHandler::GetCollection(const OString& collection_name, const OQueryPar
} else {
nlohmann::json json;
status = GetCollectionMetaInfo(collection_name->std_str(), json);
result = status.ok() ? json.dump().c_str() : "NULL";
nlohmann::json result_json;
result_json["data"] = json;
result = status.ok() ? result_json.dump().c_str() : "NULL";
}
ASSIGN_RETURN_STATUS_DTO(status);
......
......@@ -824,8 +824,8 @@ TEST_F(WebControllerTest, SEARCH) {
// auto error_dto = response->readBodyToDto<milvus::server::web::StatusDtoT>(object_mapper.get());
// 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("num"));
ASSERT_EQ(1, result_json["num"].get<int64_t>());
ASSERT_TRUE(result_json.contains("data"));
ASSERT_EQ(1, result_json["data"]["num"].get<int64_t>());
}
TEST_F(WebControllerTest, INDEX) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册