Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Allow `out_of` and `search_time_ms` to be excluded.

Kishore Nallan29d29e64a4fb
diff --git a/src/collection.cpp b/src/collection.cpp
index 8586ce8a..8a82a7c8 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -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();
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index 5d1d7f4d..fa0844a8 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -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);