Allow out_of and search_time_ms to be excluded.

This commit is contained in:
Kishore Nallan 2022-02-19 19:32:51 +05:30
parent bf475ad55f
commit 29d29e64a4
2 changed files with 9 additions and 2 deletions

View File

@ -1158,7 +1158,10 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
nlohmann::json result = nlohmann::json::object();
result["found"] = total_found;
result["out_of"] = num_documents.load();
if(exclude_fields.count("out_of") == 0) {
result["out_of"] = num_documents.load();
}
std::string hits_key = group_limit ? "grouped_hits" : "hits";
result[hits_key] = nlohmann::json::array();

View File

@ -974,7 +974,11 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re
}
nlohmann::json result = result_op.get();
result["search_time_ms"] = timeMillis;
if(exclude_fields.count("search_time_ms") == 0) {
result["search_time_ms"] = timeMillis;
}
result["page"] = std::stoi(req_params[PAGE]);
results_json_str = result.dump(-1, ' ', false, nlohmann::detail::error_handler_t::ignore);