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

Handle searchcutoff during facet population as well.

Kishore Nallan7a63d930bf5e
diff --git a/src/collection.cpp b/src/collection.cpp
index 46d118df..db6e63bd 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -1668,6 +1668,13 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query,
// populate facets
for(facet & a_facet: facets) {
+ // check for search cutoff elapse
+ if((std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().
+ time_since_epoch()).count() - search_begin_us) > search_stop_us) {
+ search_cutoff = true;
+ break;
+ }
+
nlohmann::json facet_result = nlohmann::json::object();
facet_result["field_name"] = a_facet.field_name;
facet_result["counts"] = nlohmann::json::array();